]>
diplodocus.org Git - nmh/blob - sbr/pidwait.c
a7d92119e920ba5a6b5f0b71e7a55f933c1ea69e
3 * pidwait.c -- wait for child to exit
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
11 #include <h/signals.h>
15 pidwait (pid_t id
, int sigsok
)
18 SIGNAL_HANDLER istat
= NULL
, qstat
= NULL
;
23 /* ignore a couple of signals */
24 istat
= SIGNAL (SIGINT
, SIG_IGN
);
25 qstat
= SIGNAL (SIGQUIT
, SIG_IGN
);
28 while ((pid
= waitpid(id
, &status
, 0)) == -1 && errno
== EINTR
)
32 /* reset the signal handlers */
33 SIGNAL (SIGINT
, istat
);
34 SIGNAL (SIGQUIT
, qstat
);
37 return (pid
== -1 ? -1 : status
);