3 * pidwait.c -- wait for child to exit
12 #ifdef HAVE_SYS_WAIT_H
13 # include <sys/wait.h>
17 pidwait (pid_t id, int sigsok)
21 SIGNAL_HANDLER istat, qstat;
30 /* ignore a couple of signals */
31 istat = SIGNAL (SIGINT, SIG_IGN);
32 qstat = SIGNAL (SIGQUIT, SIG_IGN);
36 pid = waitpid(id, &status, 0);
38 while ((pid = wait(&status)) != -1 && pid != id)
43 /* reset the signal handlers */
44 SIGNAL (SIGINT, istat);
45 SIGNAL (SIGQUIT, qstat);
49 return (pid == -1 ? -1 : status);
51 return (pid == -1 ? -1 : status.w_status);