|
|
1.1 ! root 1: static char sccsid[] = "@(#)netstart.c 4.1 (Berkeley) 9/12/82"; ! 2: ! 3: # include "defs.h" ! 4: /* sccs id variable */ ! 5: static char *netstart_sid = "@(#)netstart.c 1.2"; ! 6: ! 7: /* ! 8: * this is a simple program to start up the net daemon, ! 9: * and when it fails, restart it ! 10: * ! 11: */ ! 12: static int daemon = 32767; /* a nice safe process number */ ! 13: main(argc,argv) ! 14: char **argv; { ! 15: int r,killit(),pid; ! 16: while((pid = fork()) == -1)sleep(2); ! 17: if(pid != 0)exit(EX_OK); ! 18: submit(getpid()); ! 19: signal(SIGQUIT,SIG_IGN); ! 20: signal(SIGHUP,SIG_IGN); ! 21: signal(SIGINT,SIG_IGN); ! 22: signal(SIGTERM,killit); ! 23: /* will set remote */ ! 24: parseargs(argc,argv); ! 25: addtolog(remote,"Netstart started, process id #%d\n",getpid()); ! 26: for(;;){ ! 27: while((daemon=fork()) == -1)sleep(2); ! 28: if(daemon == 0){ ! 29: argv[0] = "netdaemon"; ! 30: argv[argc] = 0; ! 31: execv(NETDAEMON,argv); ! 32: exit(EX_UNAVAILABLE); ! 33: } ! 34: wait(&r); ! 35: addtolog(remote,"Net daemon exit code %d, low byte 0%o\n", ! 36: (r>>8), (r&0377)); ! 37: sleep(100); /* avoid looping too fast */ ! 38: } ! 39: } ! 40: killit(){ ! 41: kill(daemon,SIGTERM); /* send terminate */ ! 42: sleep(2); /* wait till cleanup */ ! 43: kill(daemon,SIGKILL); /* kill in case too */ ! 44: exit(EX_OK); ! 45: } ! 46: /* add to allow netstart.c to load */ ! 47: initseqno(){};
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.