summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-07-01 22:07:49 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-07-01 22:07:49 +0000
commit4aace8994dd54066a02e342f9aa7891f5ebbf232 (patch)
treeaf8e6b887700f70ea4af6baaf7505e48cfe4e7d1
parent97845c7d931be5b14eb550302ff2633e07566370 (diff)
(process_signal): On SIGCHLD, keep reaping children until we get an
error; tolerate all errors silently.
-rw-r--r--init/init.c110
1 files changed, 56 insertions, 54 deletions
diff --git a/init/init.c b/init/init.c
index 0198a4d4..ec3e8d03 100644
--- a/init/init.c
+++ b/init/init.c
@@ -1289,70 +1289,72 @@ process_signal (int signo)
{
/* A child died. Find its status. */
int status;
- pid_t pid = waitpid (WAIT_ANY, &status, WNOHANG);
- if (pid < 0)
- error (0, errno, "waitpid");
- else if (pid == 0)
- error (0, 0, "Spurious SIGCHLD");
- else if (pid == shell_pid && system_state == SINGLE)
+ pid_t pid;
+
+ for (;;)
{
- if (WIFSIGNALED (status))
- {
- error (0, 0,
- "Single-user terminated abnormally (%s), restarting",
- strsignal (WTERMSIG (status)));
- launch_single_user ();
- }
- else if (WIFSTOPPED (status))
- {
- error (0, 0,
- "Single-user stopped (%s), killing and restarting",
- strsignal (WSTOPSIG (status)));
- kill (shell_pid, SIGKILL);
- launch_single_user ();
- }
- else
+ pid = waitpid (WAIT_ANY, &status, WNOHANG);
+ if (pid <= 0)
+ return;
+
+ if (pid == shell_pid && system_state == SINGLE)
{
- do_fastboot = 1;
- fail = process_rc_script ();
- if (fail)
+ if (WIFSIGNALED (status))
{
- do_fastboot = 0;
+ error (0, 0,
+ "Single-user terminated abnormally (%s), restarting",
+ strsignal (WTERMSIG (status)));
launch_single_user ();
}
+ else if (WIFSTOPPED (status))
+ {
+ error (0, 0,
+ "Single-user stopped (%s), killing and restarting",
+ strsignal (WSTOPSIG (status)));
+ kill (shell_pid, SIGKILL);
+ launch_single_user ();
+ }
+ else
+ {
+ do_fastboot = 1;
+ fail = process_rc_script ();
+ if (fail)
+ {
+ do_fastboot = 0;
+ launch_single_user ();
+ }
+ }
}
- }
- else if (pid == rc_pid && system_state == RUNCOM)
- {
- if (WIFSIGNALED (status))
- {
- error (0, 0,
- "%s terminated abnormally (%s), going to single user mode",
- _PATH_RUNCOM, strsignal (WTERMSIG (status)));
- launch_single_user ();
- }
- else if (WIFSTOPPED (status))
+ else if (pid == rc_pid && system_state == RUNCOM)
{
- error (0, 0,
- "%s stopped (%s), killing it and going to single user mode",
- _PATH_RUNCOM, strsignal (WSTOPSIG (status)));
- kill (rc_pid, SIGKILL);
- launch_single_user ();
+ if (WIFSIGNALED (status))
+ {
+ error (0, 0,
+ "%s terminated abnormally (%s), \
+going to single user mode",
+ _PATH_RUNCOM, strsignal (WTERMSIG (status)));
+ launch_single_user ();
+ }
+ else if (WIFSTOPPED (status))
+ {
+ error (0, 0,
+ "%s stopped (%s), \
+killing it and going to single user mode",
+ _PATH_RUNCOM, strsignal (WSTOPSIG (status)));
+ kill (rc_pid, SIGKILL);
+ launch_single_user ();
+ }
+ else if (WEXITSTATUS (status))
+ launch_single_user ();
+ else
+ launch_multi_user ();
}
- else if (WEXITSTATUS (status))
- launch_single_user ();
- else
- launch_multi_user ();
+ else if (system_state == MULTI)
+ restart_terminal (pid);
+
+ break;
}
- else if (system_state == MULTI)
- restart_terminal (pid);
-#if 0
- else
- error (0, 0, "Random child pid %d died (%d)", pid, status);
-#endif
- break;
}
-
default:
break;
}