|
|
1.1 ! root 1: /* pidwait.c - wait for child to exit */ ! 2: ! 3: #include "../h/mh.h" ! 4: #include <signal.h> ! 5: #include <stdio.h> ! 6: #ifdef BSD42 ! 7: #include <sys/wait.h> ! 8: #endif BSD42 ! 9: ! 10: ! 11: int pidwait (id, sigsok) ! 12: register int id, ! 13: sigsok; ! 14: { ! 15: register int pid; ! 16: #ifndef BSD42 ! 17: int status; ! 18: #else BSD42 ! 19: union wait status; ! 20: #endif BSD42 ! 21: int (*hstat) (), (*istat) (), (*qstat) (), (*tstat) (); ! 22: ! 23: if (sigsok == NOTOK) { ! 24: hstat = signal (SIGHUP, SIG_IGN); ! 25: istat = signal (SIGINT, SIG_IGN); ! 26: qstat = signal (SIGQUIT, SIG_IGN); ! 27: tstat = signal (SIGTERM, SIG_IGN); ! 28: } ! 29: ! 30: while ((pid = wait (&status)) != NOTOK && pid != id) ! 31: continue; ! 32: ! 33: if (sigsok == NOTOK) { ! 34: (void) signal (SIGHUP, hstat); ! 35: (void) signal (SIGINT, istat); ! 36: (void) signal (SIGQUIT, qstat); ! 37: (void) signal (SIGTERM, tstat); ! 38: } ! 39: ! 40: #ifndef BSD42 ! 41: return (pid == NOTOK ? NOTOK : status); ! 42: #else BSD42 ! 43: return (pid == NOTOK ? NOTOK : status.w_status); ! 44: #endif BSD42 ! 45: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.