12a6b7db3Sskrll /*
22a6b7db3Sskrll
32a6b7db3Sskrll @deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
42a6b7db3Sskrll
52a6b7db3Sskrll This is a wrapper around the @code{wait} function. Any ``special''
62a6b7db3Sskrll values of @var{pid} depend on your implementation of @code{wait}, as
72a6b7db3Sskrll does the return value. The third argument is unused in @libib{}.
82a6b7db3Sskrll
92a6b7db3Sskrll @end deftypefn
102a6b7db3Sskrll
112a6b7db3Sskrll */
122a6b7db3Sskrll
132a6b7db3Sskrll #ifdef HAVE_CONFIG_H
142a6b7db3Sskrll #include "config.h"
152a6b7db3Sskrll #endif
162a6b7db3Sskrll #include "ansidecl.h"
172a6b7db3Sskrll
182a6b7db3Sskrll /* On some systems (such as WindISS), you must include <sys/types.h>
192a6b7db3Sskrll to get the definition of "pid_t" before you include <sys/wait.h>. */
202a6b7db3Sskrll #include <sys/types.h>
212a6b7db3Sskrll
222a6b7db3Sskrll #ifdef HAVE_SYS_WAIT_H
232a6b7db3Sskrll #include <sys/wait.h>
242a6b7db3Sskrll #endif
252a6b7db3Sskrll
26*98f124a6Schristos #ifdef __MINGW32__
27*98f124a6Schristos #include <process.h>
28*98f124a6Schristos #define wait(s) _cwait(s,pid,_WAIT_CHILD)
29*98f124a6Schristos #endif
30*98f124a6Schristos
312a6b7db3Sskrll pid_t
waitpid(pid_t pid,int * stat_loc,int options ATTRIBUTE_UNUSED)322a6b7db3Sskrll waitpid (pid_t pid, int *stat_loc, int options ATTRIBUTE_UNUSED)
332a6b7db3Sskrll {
342a6b7db3Sskrll for (;;)
352a6b7db3Sskrll {
362a6b7db3Sskrll int wpid = wait(stat_loc);
372a6b7db3Sskrll if (wpid == pid || wpid == -1)
382a6b7db3Sskrll return wpid;
392a6b7db3Sskrll }
402a6b7db3Sskrll }
41