Skip to content

Commit

Permalink
signal_handler: Reports pid 0 as Kernel
Browse files Browse the repository at this point in the history
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: <unknown> UID: 0

This commit is about returning an explicit "Kernel" as a task name if pid is 0

Signed-off-by: Erwan Velu <erwan@redhat.com>
  • Loading branch information
Erwan Velu committed Apr 4, 2018
1 parent 806072a commit 82ab412
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/global/signal_handler.cc
Expand Up @@ -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);
Expand Down

0 comments on commit 82ab412

Please sign in to comment.