1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

Userland: Fix kill to support negative pid values.

The kill system call accepts negative pids, as they
have special meaning:

    pid == -1 means all processes the calling process has access to.

    pid < -1 means every process who's process group ID is -pid.

I don't see any reason why the user space program should mask this.
This commit is contained in:
Brian Gianforcaro 2020-04-25 17:41:14 -07:00 committed by Andreas Kling
parent 1f64e3eb16
commit 597ff9ec93

View file

@ -58,13 +58,13 @@ int main(int argc, char** argv)
return 2; return 2;
} }
} }
unsigned pid = String(argv[pid_argi]).to_uint(ok); pid_t pid = String(argv[pid_argi]).to_int(ok);
if (!ok) { if (!ok) {
printf("'%s' is not a valid PID\n", argv[pid_argi]); printf("'%s' is not a valid PID\n", argv[pid_argi]);
return 3; return 3;
} }
int rc = kill((pid_t)pid, signum); int rc = kill(pid, signum);
if (rc < 0) if (rc < 0)
perror("kill"); perror("kill");
return 0; return 0;