1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

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
parent 6aa2b7d4cc
commit 5fbb476856

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)