]>
diplodocus.org Git - nmh/blob - sbr/pidwait.c
3 * pidwait.c -- wait for child to exit
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
13 #include <h/signals.h>
16 #ifdef HAVE_SYS_WAIT_H
17 # include <sys/wait.h>
21 pidwait (pid_t id
, int sigsok
)
24 SIGNAL_HANDLER istat
, qstat
;
33 /* ignore a couple of signals */
34 istat
= SIGNAL (SIGINT
, SIG_IGN
);
35 qstat
= SIGNAL (SIGQUIT
, SIG_IGN
);
39 pid
= waitpid(id
, &status
, 0);
41 while ((pid
= wait(&status
)) != -1 && pid
!= id
)
46 /* reset the signal handlers */
47 SIGNAL (SIGINT
, istat
);
48 SIGNAL (SIGQUIT
, qstat
);
52 return (pid
== -1 ? -1 : status
);
54 return (pid
== -1 ? -1 : status
.w_status
);