]>
diplodocus.org Git - nmh/blob - sbr/pidwait.c
1 /* pidwait.c -- wait for child to exit
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
12 pidwait (pid_t id
, int sigsok
)
15 SIGNAL_HANDLER istat
= NULL
, qstat
= NULL
;
20 /* ignore a couple of signals */
21 istat
= SIGNAL (SIGINT
, SIG_IGN
);
22 qstat
= SIGNAL (SIGQUIT
, SIG_IGN
);
25 while ((pid
= waitpid(id
, &status
, 0)) == -1 && errno
== EINTR
)
29 /* reset the signal handlers */
30 SIGNAL (SIGINT
, istat
);
31 SIGNAL (SIGQUIT
, qstat
);
34 return (pid
== -1 ? -1 : status
);