1*13571821Stholo /* waitpid.c --- waiting for process termination, under OS/2 2*13571821Stholo Karl Fogel <kfogel@cyclic.com> --- November 1995 */ 3*13571821Stholo 4*13571821Stholo #include <assert.h> 5*13571821Stholo #include <stdio.h> 6*13571821Stholo #include <process.h> 7*13571821Stholo #include <errno.h> 8*13571821Stholo 9*13571821Stholo #include "config.h" 10*13571821Stholo 11*13571821Stholo /* Wait for the process PID to exit. Put the return status in *statusp. 12*13571821Stholo OPTIONS is not supported yet under OS/2. We hope it's always zero. */ waitpid(pid,statusp,options)13*13571821Stholopid_t waitpid (pid, statusp, options) 14*13571821Stholo pid_t pid; 15*13571821Stholo int *statusp; 16*13571821Stholo int options; 17*13571821Stholo { 18*13571821Stholo pid_t rc; 19*13571821Stholo 20*13571821Stholo /* We don't know how to deal with any options yet. */ 21*13571821Stholo assert (options == 0); 22*13571821Stholo 23*13571821Stholo rc = _cwait (statusp, pid, WAIT_CHILD); 24*13571821Stholo 25*13571821Stholo if (rc == -1) 26*13571821Stholo { 27*13571821Stholo if (errno == ECHILD) 28*13571821Stholo return pid; 29*13571821Stholo else 30*13571821Stholo return -1; 31*13571821Stholo } 32*13571821Stholo else if (rc == pid) 33*13571821Stholo return pid; 34*13571821Stholo else 35*13571821Stholo return -1; 36*13571821Stholo } 37