Hello,
This patch to init improves the log message when a process exits to also print
whether it exited normally or because of a signal, as well as the status code
and signal number.
From f46ecee6ff78fae6db0710016046cb46d06ee5fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Parisot?= <[email protected]>
Date: Wed, 2 Apr 2025 17:43:54 +0200
Subject: [PATCH] init: improved log message when a process exit to include its
exit code or signal number
---
init/init.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/init/init.c b/init/init.c
index 2ee1e4cde..9a979a5ec 100644
--- a/init/init.c
+++ b/init/init.c
@@ -1198,17 +1198,20 @@ int init_main(int argc UNUSED_PARAM, char **argv)
/* Wait for any child process(es) to exit */
while (1) {
pid_t wpid;
+ int status;
struct init_action *a;
- wpid = waitpid(-1, NULL, WNOHANG);
+ wpid = waitpid(-1, &status, WNOHANG);
if (wpid <= 0)
break;
a = mark_terminated(wpid);
if (a) {
- message(L_LOG, "process '%s' (pid %u) exited. "
+ message(L_LOG, "process '%s' (pid %u) exited [EXIT=%s/%d SIGNAL=%s/%d]. "
"Scheduling for restart.",
- a->command, (unsigned)wpid);
+ a->command, (unsigned)wpid,
+ WIFEXITED(status) ? "true" : "false", WIFEXITED(status) ? WEXITSTATUS(status) : -1,
+ WIFSIGNALED(status) ? "true" : "false", WIFSIGNALED(status) ? WTERMSIG(status) : -1);
}
}
--
2.39.5
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox