|
|
1.1 ! root 1: /* push.c - push a fork into the background */ ! 2: ! 3: #include "../h/mh.h" ! 4: #include <stdio.h> ! 5: #include <signal.h> ! 6: ! 7: ! 8: void push () { ! 9: register int i; ! 10: ! 11: for (i = 0; i < 5; i++) { ! 12: switch (fork ()) { ! 13: case NOTOK: ! 14: sleep (5); ! 15: continue; ! 16: ! 17: case OK: ! 18: (void) signal (SIGHUP, SIG_IGN); ! 19: (void) signal (SIGINT, SIG_IGN); ! 20: (void) signal (SIGQUIT, SIG_IGN); ! 21: (void) signal (SIGTERM, SIG_IGN); ! 22: #ifdef SIGTSTP ! 23: (void) signal (SIGTSTP, SIG_IGN); ! 24: (void) signal (SIGTTIN, SIG_IGN); ! 25: (void) signal (SIGTTOU, SIG_IGN); ! 26: #endif SIGTSTP ! 27: (void) freopen ("/dev/null", "r", stdin); ! 28: (void) freopen ("/dev/null", "w", stdout); ! 29: break; ! 30: ! 31: default: ! 32: done (0); ! 33: } ! 34: break; ! 35: } ! 36: if (i >= 5) ! 37: advise (NULLCP, "unable to fork, so can't push..."); ! 38: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.