waitpid.c revision 89857
1180740Sdes/*
2180740Sdes
3294332Sdes@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
4180740Sdes
5180740SdesThis is a wrapper around the @code{wait} function.  Any ``special''
6197670Sdesvalues of @var{pid} depend on your implementation of @code{wait}, as
7197670Sdesdoes the return value.  The third argument is unused in @libib{}.
8197670Sdes
9197670Sdes@end deftypefn
10197670Sdes
11197670Sdes*/
12197670Sdes
13197670Sdes#ifdef HAVE_CONFIG_H
14197670Sdes#include "config.h"
15197670Sdes#endif
16197670Sdes#ifdef HAVE_SYS_WAIT_H
17197670Sdes#include <sys/wait.h>
18180740Sdes#endif
19180750Sdes
20180750Sdesint
21180750Sdeswaitpid (pid, stat_loc, options)
22180750Sdes	int pid, *stat_loc, options;
23180750Sdes{
24180750Sdes  for (;;)
25221377Sdes    {
26221377Sdes      int wpid = wait(stat_loc);
27221377Sdes      if (wpid == pid || wpid == -1)
28221377Sdes	return wpid;
29221377Sdes    }
30221377Sdes}
31221377Sdes