From 5fbb4768562c871771a940a48171499d72096f22 Mon Sep 17 00:00:00 2001 From: Marcus Nilsson Date: Tue, 27 Jul 2021 22:52:32 +0200 Subject: [PATCH] SystemMonitor: Use kill(pid,0) when checking for kill permission We can use kill(pid,0) to check for kill permissions instead of relying on file path access. Using 0 as signal does error checking but does not send a signal. --- Userland/Applications/SystemMonitor/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index 5236793fb4..5afeae9461 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -87,8 +87,8 @@ private: static bool can_access_pid(pid_t pid) { - auto path = String::formatted("/proc/{}", pid); - return access(path.characters(), X_OK) == 0; + int rc = kill(pid, 0); + return rc == 0; } int main(int argc, char** argv)