116dce513Schristos /*
216dce513Schristos
316dce513Schristos @deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
416dce513Schristos
516dce513Schristos This is a wrapper around the @code{wait} function. Any ``special''
616dce513Schristos values of @var{pid} depend on your implementation of @code{wait}, as
716dce513Schristos does the return value. The third argument is unused in @libib{}.
816dce513Schristos
916dce513Schristos @end deftypefn
1016dce513Schristos
1116dce513Schristos */
1216dce513Schristos
1316dce513Schristos #ifdef HAVE_CONFIG_H
1416dce513Schristos #include "config.h"
1516dce513Schristos #endif
1616dce513Schristos #include "ansidecl.h"
1716dce513Schristos
1816dce513Schristos /* On some systems (such as WindISS), you must include <sys/types.h>
1916dce513Schristos to get the definition of "pid_t" before you include <sys/wait.h>. */
2016dce513Schristos #include <sys/types.h>
2116dce513Schristos
2216dce513Schristos #ifdef HAVE_SYS_WAIT_H
2316dce513Schristos #include <sys/wait.h>
2416dce513Schristos #endif
2516dce513Schristos
26*ede78133Schristos #ifdef __MINGW32__
27*ede78133Schristos #include <process.h>
28*ede78133Schristos #define wait(s) _cwait(s,pid,_WAIT_CHILD)
29*ede78133Schristos #endif
30*ede78133Schristos
3116dce513Schristos pid_t
waitpid(pid_t pid,int * stat_loc,int options ATTRIBUTE_UNUSED)3216dce513Schristos waitpid (pid_t pid, int *stat_loc, int options ATTRIBUTE_UNUSED)
3316dce513Schristos {
3416dce513Schristos for (;;)
3516dce513Schristos {
3616dce513Schristos int wpid = wait(stat_loc);
3716dce513Schristos if (wpid == pid || wpid == -1)
3816dce513Schristos return wpid;
3916dce513Schristos }
4016dce513Schristos }
41