File: waitpid.c

package info (click to toggle)
cvs 1.10.7-1.99.slink.y2k.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,892 kB
  • ctags: 5,463
  • sloc: ansic: 68,307; sh: 17,664; makefile: 1,640; perl: 902; yacc: 826; csh: 181; lisp: 7
file content (36 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* waitpid.c --- waiting for process termination, under OS/2
   Karl Fogel <kfogel@cyclic.com> --- November 1995  */

#include <assert.h>
#include <stdio.h>
#include <process.h>
#include <errno.h>

#include "config.h"

/* Wait for the process PID to exit.  Put the return status in *statusp.
   OPTIONS is not supported yet under OS/2.  We hope it's always zero.  */
pid_t waitpid (pid, statusp, options)
     pid_t pid;
     int *statusp;
     int options;
{
  pid_t rc;

  /* We don't know how to deal with any options yet.  */
  assert (options == 0);
  
  rc = _cwait (statusp, pid, WAIT_CHILD);
  
  if (rc == -1)
    {
      if (errno == ECHILD)
        return pid;
      else
        return -1;
    }
  else if (rc == pid)
    return pid;
  else
    return -1;
}