1169695Skan/*
2169695Skan
3169695Skan@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
4169695Skan
5169695SkanThis is a wrapper around the @code{wait} function.  Any ``special''
6169695Skanvalues of @var{pid} depend on your implementation of @code{wait}, as
7169695Skandoes the return value.  The third argument is unused in @libib{}.
8169695Skan
9169695Skan@end deftypefn
10169695Skan
11169695Skan*/
12169695Skan
13169695Skan#ifdef HAVE_CONFIG_H
14169695Skan#include "config.h"
15169695Skan#endif
16169695Skan#include "ansidecl.h"
17169695Skan
18169695Skan/* On some systems (such as WindISS), you must include <sys/types.h>
19169695Skan   to get the definition of "pid_t" before you include <sys/wait.h>.  */
20169695Skan#include <sys/types.h>
21169695Skan
22169695Skan#ifdef HAVE_SYS_WAIT_H
23169695Skan#include <sys/wait.h>
24169695Skan#endif
25169695Skan
26169695Skanpid_t
27169695Skanwaitpid (pid_t pid, int *stat_loc, int options ATTRIBUTE_UNUSED)
28169695Skan{
29169695Skan  for (;;)
30169695Skan    {
31169695Skan      int wpid = wait(stat_loc);
32169695Skan      if (wpid == pid || wpid == -1)
33169695Skan	return wpid;
34169695Skan    }
35169695Skan}
36