0
|
1 /* push.c - push a fork into the background */
|
|
2 #ifndef lint
|
|
3 static char ident[] = "@(#)$Id$";
|
|
4 #endif /* lint */
|
|
5
|
|
6 #include "../h/mh.h"
|
|
7 #include <stdio.h>
|
|
8 #include <signal.h>
|
|
9
|
|
10
|
|
11 void push () {
|
|
12 register int i;
|
|
13
|
|
14 for (i = 0; i < 5; i++) {
|
|
15 switch (fork ()) {
|
|
16 case NOTOK:
|
|
17 sleep (5);
|
|
18 continue;
|
|
19
|
|
20 case OK:
|
|
21 (void) signal (SIGHUP, SIG_IGN);
|
|
22 (void) signal (SIGINT, SIG_IGN);
|
|
23 (void) signal (SIGQUIT, SIG_IGN);
|
|
24 (void) signal (SIGTERM, SIG_IGN);
|
|
25 #ifdef SIGTSTP
|
|
26 (void) signal (SIGTSTP, SIG_IGN);
|
|
27 (void) signal (SIGTTIN, SIG_IGN);
|
|
28 (void) signal (SIGTTOU, SIG_IGN);
|
|
29 #endif /* SIGTSTP */
|
|
30 (void) freopen ("/dev/null", "r", stdin);
|
|
31 (void) freopen ("/dev/null", "w", stdout);
|
|
32 break;
|
|
33
|
|
34 default:
|
|
35 done (0);
|
|
36 }
|
|
37 break;
|
|
38 }
|
|
39 if (i >= 5)
|
|
40 advise (NULLCP, "unable to fork, so can't push...");
|
|
41 }
|