]>
Commit | Line | Data |
---|---|---|
d5dd40c4 MM |
1 | diff -ur busybox-0.60.2/init.c busybox-0.60.2-/init.c |
2 | --- busybox-0.60.2/init.c Sun Jul 28 12:45:54 2002 | |
3 | +++ busybox-0.60.2-/init.c Sun Jul 28 12:43:02 2002 | |
4 | @@ -898,13 +898,34 @@ | |
5 | #endif /* BB_FEATURE_USE_INITTAB */ | |
6 | } | |
7 | ||
8 | +static void rape_child(int sig) | |
9 | +{ | |
10 | + pid_t wpid; | |
11 | + int status; | |
12 | + initAction *a; | |
13 | + | |
14 | + /* Wait for a child process to exit */ | |
15 | + wpid = wait(&status); | |
16 | + if (wpid > 0) { | |
17 | + /* Find out who died and clean up their corpse */ | |
18 | + for (a = initActionList; a; a = a->nextPtr) { | |
19 | + if (a->pid == wpid) { | |
20 | + a->pid = 0; | |
21 | + message(LOG, | |
22 | + "Process '%s' (pid %d) exited. Scheduling it for restart.\n", | |
23 | + a->process, wpid); | |
24 | + } | |
25 | + } | |
26 | + } | |
27 | + | |
28 | + signal(sig, rape_child); | |
29 | +} | |
30 | + | |
31 | ||
32 | ||
33 | extern int init_main(int argc, char **argv) | |
34 | { | |
35 | initAction *a, *tmp; | |
36 | - pid_t wpid; | |
37 | - int status; | |
38 | ||
39 | #ifndef DEBUG_INIT | |
40 | /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */ | |
41 | @@ -1001,6 +1022,8 @@ | |
42 | loop_forever(); | |
43 | } | |
44 | ||
45 | + signal(SIGCHLD, rape_child); | |
46 | + | |
47 | /* Now run the looping stuff for the rest of forever */ | |
48 | while (1) { | |
49 | for (a = initActionList; a; a = a->nextPtr) { | |
50 | @@ -1022,19 +1045,6 @@ | |
51 | } | |
52 | } | |
53 | } | |
54 | - /* Wait for a child process to exit */ | |
55 | - wpid = wait(&status); | |
56 | - if (wpid > 0) { | |
57 | - /* Find out who died and clean up their corpse */ | |
58 | - for (a = initActionList; a; a = a->nextPtr) { | |
59 | - if (a->pid == wpid) { | |
60 | - a->pid = 0; | |
61 | - message(LOG, | |
62 | - "Process '%s' (pid %d) exited. Scheduling it for restart.\n", | |
63 | - a->process, wpid); | |
64 | - } | |
65 | - } | |
66 | - } | |
67 | sleep(1); | |
68 | } | |
69 | } |