|
|
BSD 4.3reno
/* pidwait.c - wait for child to exit */
#include "../h/mh.h"
#include <signal.h>
#include <stdio.h>
#if defined(POSIX) || defined(BSD42)
#include <sys/wait.h>
#endif POSIX or BSD42
pidwait(id, sigsok)
register int id, sigsok;
{
register int pid;
SIGDECL (*hstat)(), (*istat)(), (*qstat)(), (*tstat)();
#ifndef BSD42
int status;
#else BSD42
union wait status;
#endif BSD42
if (sigsok == NOTOK) {
hstat = signal (SIGHUP, SIG_IGN);
istat = signal (SIGINT, SIG_IGN);
qstat = signal (SIGQUIT, SIG_IGN);
tstat = signal (SIGTERM, SIG_IGN);
}
#ifdef POSIX
pid = waitpid(id, &status, 0);
#else
while ((pid = wait (&status)) != NOTOK && pid != id)
continue;
#endif
if (sigsok == NOTOK) {
(void) signal (SIGHUP, hstat);
(void) signal (SIGINT, istat);
(void) signal (SIGQUIT, qstat);
(void) signal (SIGTERM, tstat);
}
#if defined(POSIX) || !defined(BSD42)
return (pid == NOTOK ? NOTOK : status);
#else
return (pid == NOTOK ? NOTOK : status.w_status);
#endif
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.