mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 12:17:52 +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:
parent
6aa2b7d4cc
commit
5fbb476856
Notes:
sideshowbarker
2024-07-18 07:48:11 +09:00
Author: https://github.com/metmo
Commit: 5fbb476856
Pull-request: https://github.com/SerenityOS/serenity/pull/9064
Reviewed-by: https://github.com/awesomekling
1 changed files with 2 additions and 2 deletions
|
@ -87,8 +87,8 @@ private:
|
||||||
|
|
||||||
static bool can_access_pid(pid_t pid)
|
static bool can_access_pid(pid_t pid)
|
||||||
{
|
{
|
||||||
auto path = String::formatted("/proc/{}", pid);
|
int rc = kill(pid, 0);
|
||||||
return access(path.characters(), X_OK) == 0;
|
return rc == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue