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)
20 SIGNAL_HANDLER istat, qstat;
29 /* ignore a couple of signals */
30 istat = SIGNAL (SIGINT, SIG_IGN);
31 qstat = SIGNAL (SIGQUIT, SIG_IGN);
35 pid = waitpid(id, &status, 0);
37 while ((pid = wait(&status)) != -1 && pid != id)
42 /* reset the signal handlers */
43 SIGNAL (SIGINT, istat);
44 SIGNAL (SIGQUIT, qstat);
48 return (pid == -1 ? -1 : status);
50 return (pid == -1 ? -1 : status.w_status);