Annotation of 3BSD/cmd/net/netstart.c, revision 1.1

1.1     ! root        1: # include <stdio.h>
        !             2: # include "mach.h"
        !             3: # include "Paths.h"
        !             4: /*
        !             5:  * this is a simple program to start up the net daemon,
        !             6:  * and when it fails, restart it
        !             7:  * 
        !             8:  * 
        !             9:  */
        !            10: static int daemon = 32767;             /* a nice safe process number */
        !            11: main(argc,argv)
        !            12:   char **argv; {
        !            13:        char *s,mchTo;
        !            14:        int r,killit(),pid;
        !            15:        while((pid = fork()) == -1)sleep(2);
        !            16:        if(pid != 0)exit(0);
        !            17:        submit(getpid());
        !            18:        signal(SIGQUIT,SIG_IGN);
        !            19:        signal(SIGHUP,SIG_IGN);
        !            20:        signal(SIGINT,SIG_IGN);
        !            21:        signal(SIGTRM,killit);
        !            22:        s = argc == 1 ? 0 : argv[1];
        !            23:        mchTo = argc == 1 ? 'a' : lookup(s);
        !            24:        for(;;){
        !            25:                while((daemon=fork()) == -1)sleep(2);
        !            26:                if(daemon == 0){
        !            27:                        execl(NETDAEMON,"netdaemon",s,0);
        !            28:                        exit(1);
        !            29:                        }
        !            30:                wait(&r);
        !            31:                addtolog(mchTo,"Net daemon exit code %d, low byte %o\n",
        !            32:                        (r>>8), (r&0377));
        !            33:                sleep(100);             /* avoid looping too fast */
        !            34:                }
        !            35:        }
        !            36: killit(){
        !            37:        kill(daemon,SIGTRM);            /* send terminate */
        !            38:        sleep(2);                       /* wait till cleanup */
        !            39:        kill(daemon,SIGKIL);            /* kill in case too */
        !            40:        exit(0);
        !            41:        }

unix.superglobalmegacorp.com

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