From b21467d32601805a167d9e59f7a1c5250b8fff0e Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Thu, 22 Mar 2018 06:14:22 +0100 Subject: [PATCH] signal_handler: Reports pid 0 as Kernel When receiving a signal, get_name_by_pid() tries to find what was the process name of the sender. As per bug #23320, we have case where pid is 0 leading to the following confusing message : signal: Interrupt from PID: 0 task name: UID: 0 This commit is about returning an explicit "Kernel" as a task name if pid is 0 Signed-off-by: Erwan Velu --- src/global/signal_handler.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index 9d57638975b..5764fb3e8f7 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -175,6 +175,10 @@ string get_name_by_pid(pid_t pid) #else string get_name_by_pid(pid_t pid) { + // If the PID is 0, its means the sender is the Kernel itself + if (pid == 0) { + return "Kernel"; + } char proc_pid_path[PATH_MAX] = {0}; snprintf(proc_pid_path, PATH_MAX, PROCPREFIX "/proc/%d/cmdline", pid); int fd = open(proc_pid_path, O_RDONLY); -- 2.39.5