diff options
Diffstat (limited to '')
-rw-r--r-- | init/init.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/init/init.c b/init/init.c index 2ee1e4cde..797e0a0eb 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -1198,17 +1198,29 @@ int init_main(int argc UNUSED_PARAM, char **argv) | |||
1198 | /* Wait for any child process(es) to exit */ | 1198 | /* Wait for any child process(es) to exit */ |
1199 | while (1) { | 1199 | while (1) { |
1200 | pid_t wpid; | 1200 | pid_t wpid; |
1201 | int status; | ||
1201 | struct init_action *a; | 1202 | struct init_action *a; |
1202 | 1203 | ||
1203 | wpid = waitpid(-1, NULL, WNOHANG); | 1204 | wpid = waitpid(-1, &status, WNOHANG); |
1204 | if (wpid <= 0) | 1205 | if (wpid <= 0) |
1205 | break; | 1206 | break; |
1206 | 1207 | ||
1207 | a = mark_terminated(wpid); | 1208 | a = mark_terminated(wpid); |
1208 | if (a) { | 1209 | if (a) { |
1209 | message(L_LOG, "process '%s' (pid %u) exited. " | 1210 | const char *s = "killed, signal"; |
1211 | int ex = WTERMSIG(status); | ||
1212 | /* "if (!WIFSIGNALED(status))" generates more code: | ||
1213 | * on linux, WIFEXITED(status) is "WTERMSIG(status) == 0" | ||
1214 | * and WTERMSIG(status) is known, so compiler optimizes. | ||
1215 | */ | ||
1216 | if (WIFEXITED(status)) { | ||
1217 | s = "exited, exitcode"; | ||
1218 | ex = WEXITSTATUS(status); | ||
1219 | } | ||
1220 | message(L_LOG, "process '%s' (pid %u) %s:%d. " | ||
1210 | "Scheduling for restart.", | 1221 | "Scheduling for restart.", |
1211 | a->command, (unsigned)wpid); | 1222 | a->command, (unsigned)wpid, |
1223 | s, ex); | ||
1212 | } | 1224 | } |
1213 | } | 1225 | } |
1214 | 1226 | ||