aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorSébastien Parisot <sparisot@free-mobile.fr>2025-04-02 17:43:54 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-04-06 10:44:04 +0200
commitf9274e8d6e15d1c3cc0368aa55974de84bbbb002 (patch)
tree460c00af4771cb2098355b43f4372d5618b33cff /init
parent887295686dbc69e5b2d530f0e6a8dbf94094ac9f (diff)
downloadbusybox-w32-f9274e8d6e15d1c3cc0368aa55974de84bbbb002.tar.gz
busybox-w32-f9274e8d6e15d1c3cc0368aa55974de84bbbb002.tar.bz2
busybox-w32-f9274e8d6e15d1c3cc0368aa55974de84bbbb002.zip
init: improve log message when a process exits: show exit code
function old new delta .rodata 105649 105680 +31 init_main 776 804 +28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 59/0) Total: 59 bytes Signed-off-by: Sébastien Parisot <sparisot@free-mobile.fr> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init')
-rw-r--r--init/init.c18
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