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.
This commit is contained in:
Marcus Nilsson 2021-07-27 22:52:32 +02:00 committed by Andreas Kling
commit 5fbb476856
Notes: sideshowbarker 2024-07-18 07:48:11 +09:00

View file

@ -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)