Revision 12455,
867 bytes
checked in by danw, 26 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r12454,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | |
---|
2 | /* |
---|
3 | * push.c -- push a fork into the background |
---|
4 | * |
---|
5 | * $Id: push.c,v 1.1.1.1 1999-02-07 18:14:09 danw Exp $ |
---|
6 | */ |
---|
7 | |
---|
8 | #include <h/mh.h> |
---|
9 | #include <h/signals.h> |
---|
10 | #include <signal.h> |
---|
11 | |
---|
12 | |
---|
13 | void |
---|
14 | push(void) |
---|
15 | { |
---|
16 | pid_t pid; |
---|
17 | int i; |
---|
18 | |
---|
19 | for (i = 0; (pid = fork()) == -1 && i < 5; i++) |
---|
20 | sleep (5); |
---|
21 | |
---|
22 | switch (pid) { |
---|
23 | case -1: |
---|
24 | /* fork error */ |
---|
25 | advise (NULL, "unable to fork, so can't push..."); |
---|
26 | break; |
---|
27 | |
---|
28 | case 0: |
---|
29 | /* child, block a few signals and continue */ |
---|
30 | SIGNAL (SIGHUP, SIG_IGN); |
---|
31 | SIGNAL (SIGINT, SIG_IGN); |
---|
32 | SIGNAL (SIGQUIT, SIG_IGN); |
---|
33 | SIGNAL (SIGTERM, SIG_IGN); |
---|
34 | #ifdef SIGTSTP |
---|
35 | SIGNAL (SIGTSTP, SIG_IGN); |
---|
36 | SIGNAL (SIGTTIN, SIG_IGN); |
---|
37 | SIGNAL (SIGTTOU, SIG_IGN); |
---|
38 | #endif |
---|
39 | freopen ("/dev/null", "r", stdin); |
---|
40 | freopen ("/dev/null", "w", stdout); |
---|
41 | break; |
---|
42 | |
---|
43 | default: |
---|
44 | /* parent, just exit */ |
---|
45 | done (0); |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
Note: See
TracBrowser
for help on using the repository browser.