]> diplodocus.org Git - nmh/blob - sbr/push.c
Fix test for inlineonly.
[nmh] / sbr / push.c
1
2 /*
3 * push.c -- push a fork into the background
4 *
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
8 */
9
10 #include <h/mh.h>
11 #include <h/signals.h>
12
13
14 void
15 push(void)
16 {
17 pid_t pid;
18 int i;
19
20 for (i = 0; (pid = fork()) == -1 && i < 5; i++)
21 sleep (5);
22
23 switch (pid) {
24 case -1:
25 /* fork error */
26 advise (NULL, "unable to fork, so can't push...");
27 break;
28
29 case 0:
30 /* child, block a few signals and continue */
31 SIGNAL (SIGHUP, SIG_IGN);
32 SIGNAL (SIGINT, SIG_IGN);
33 SIGNAL (SIGQUIT, SIG_IGN);
34 SIGNAL (SIGTERM, SIG_IGN);
35 #ifdef SIGTSTP
36 SIGNAL (SIGTSTP, SIG_IGN);
37 SIGNAL (SIGTTIN, SIG_IGN);
38 SIGNAL (SIGTTOU, SIG_IGN);
39 #endif
40
41 unregister_for_removal(0);
42
43 freopen ("/dev/null", "r", stdin);
44 freopen ("/dev/null", "w", stdout);
45 break;
46
47 default:
48 /* parent, just exit */
49 done (0);
50 }
51 }
52