Back to index

cell-binutils  2.17cvs20070401
waitpid.c
Go to the documentation of this file.
00001 /*
00002 
00003 @deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
00004 
00005 This is a wrapper around the @code{wait} function.  Any ``special''
00006 values of @var{pid} depend on your implementation of @code{wait}, as
00007 does the return value.  The third argument is unused in @libib{}.
00008 
00009 @end deftypefn
00010 
00011 */
00012 
00013 #ifdef HAVE_CONFIG_H
00014 #include "config.h"
00015 #endif
00016 #include "ansidecl.h"
00017 
00018 /* On some systems (such as WindISS), you must include <sys/types.h>
00019    to get the definition of "pid_t" before you include <sys/wait.h>.  */
00020 #include <sys/types.h>
00021 
00022 #ifdef HAVE_SYS_WAIT_H
00023 #include <sys/wait.h>
00024 #endif
00025 
00026 pid_t
00027 waitpid (pid_t pid, int *stat_loc, int options ATTRIBUTE_UNUSED)
00028 {
00029   for (;;)
00030     {
00031       int wpid = wait(stat_loc);
00032       if (wpid == pid || wpid == -1)
00033        return wpid;
00034     }
00035 }