Home | History | Annotate | Line # | Download | only in libiberty
      1      1.1  christos /*
      2      1.1  christos 
      3      1.1  christos @deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
      4      1.1  christos 
      5      1.1  christos This is a wrapper around the @code{wait} function.  Any ``special''
      6      1.1  christos values of @var{pid} depend on your implementation of @code{wait}, as
      7      1.1  christos does the return value.  The third argument is unused in @libib{}.
      8      1.1  christos 
      9      1.1  christos @end deftypefn
     10      1.1  christos 
     11      1.1  christos */
     12      1.1  christos 
     13      1.1  christos #ifdef HAVE_CONFIG_H
     14      1.1  christos #include "config.h"
     15      1.1  christos #endif
     16      1.1  christos #include "ansidecl.h"
     17      1.1  christos 
     18      1.1  christos /* On some systems (such as WindISS), you must include <sys/types.h>
     19      1.1  christos    to get the definition of "pid_t" before you include <sys/wait.h>.  */
     20      1.1  christos #include <sys/types.h>
     21      1.1  christos 
     22      1.1  christos #ifdef HAVE_SYS_WAIT_H
     23      1.1  christos #include <sys/wait.h>
     24      1.1  christos #endif
     25      1.1  christos 
     26  1.1.1.2  christos #ifdef __MINGW32__
     27  1.1.1.2  christos #include <process.h>
     28  1.1.1.2  christos #define wait(s)  _cwait(s,pid,_WAIT_CHILD)
     29  1.1.1.2  christos #endif
     30  1.1.1.2  christos 
     31      1.1  christos pid_t
     32      1.1  christos waitpid (pid_t pid, int *stat_loc, int options ATTRIBUTE_UNUSED)
     33      1.1  christos {
     34      1.1  christos   for (;;)
     35      1.1  christos     {
     36      1.1  christos       int wpid = wait(stat_loc);
     37      1.1  christos       if (wpid == pid || wpid == -1)
     38      1.1  christos 	return wpid;
     39      1.1  christos     }
     40      1.1  christos }
     41