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
Notes: sideshowbarker 2024-07-19 07:17:29 +09:00

View File

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