home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / cvs-1.8 / cvs-1 / cvs-1.8.1 / os2 / waitpid.c < prev   
Encoding:
C/C++ Source or Header  |  1996-05-06  |  770 b   |  37 lines

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