Annotation of 43BSDReno/contrib/mh/sbr/pidwait.c, revision 1.1

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: #if defined(POSIX) || defined(BSD42)
        !             7: #include <sys/wait.h>
        !             8: #endif POSIX or BSD42
        !             9: 
        !            10: 
        !            11: pidwait(id, sigsok)
        !            12:        register int id, sigsok;
        !            13: {
        !            14:     register int    pid;
        !            15:     SIGDECL (*hstat)(), (*istat)(), (*qstat)(), (*tstat)();
        !            16: #ifndef        BSD42
        !            17:     int     status;
        !            18: #else  BSD42
        !            19:     union wait status;
        !            20: #endif BSD42
        !            21: 
        !            22:     if (sigsok == NOTOK) {
        !            23:        hstat = signal (SIGHUP, SIG_IGN);
        !            24:        istat = signal (SIGINT, SIG_IGN);
        !            25:        qstat = signal (SIGQUIT, SIG_IGN);
        !            26:        tstat = signal (SIGTERM, SIG_IGN);
        !            27:     }
        !            28: 
        !            29: #ifdef POSIX
        !            30:     pid = waitpid(id, &status, 0);
        !            31: #else
        !            32:     while ((pid = wait (&status)) != NOTOK && pid != id)
        !            33:        continue;
        !            34: #endif
        !            35: 
        !            36:     if (sigsok == NOTOK) {
        !            37:        (void) signal (SIGHUP, hstat);
        !            38:        (void) signal (SIGINT, istat);
        !            39:        (void) signal (SIGQUIT, qstat);
        !            40:        (void) signal (SIGTERM, tstat);
        !            41:     }
        !            42: 
        !            43: #if defined(POSIX) || !defined(BSD42)
        !            44:     return (pid == NOTOK ? NOTOK : status);
        !            45: #else
        !            46:     return (pid == NOTOK ? NOTOK : status.w_status);
        !            47: #endif
        !            48: }
        !            49: 
        !            50: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.