Kernel: Don't assert on sys$kill() with pid=INT32_MIN

On 32-bit platforms, INT32_MIN == -INT32_MIN, so we can't expect this
to always work:

    if (pid < 0)
        positive_pid = -pid; // may still be negative!

This happens because the -INT32_MIN expression becomes a long and is
then truncated back to an int.

Fixes #1312.
This commit is contained in:
Andreas Kling 2020-02-27 09:58:53 +01:00
parent 22259bf85d
commit d28fa89346
Notes: sideshowbarker 2024-07-19 09:02:55 +09:00

View file

@ -2213,8 +2213,11 @@ int Process::sys$kill(pid_t pid, int signal)
if (signal < 0 || signal >= 32)
return -EINVAL;
if (pid <= 0)
if (pid <= 0) {
if (pid == INT32_MIN)
return -EINVAL;
return do_killpg(-pid, signal);
}
if (pid == -1) {
// FIXME: Send to all processes.
return -ENOTIMPL;