mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
Kernel: kill() with signal 0 should not actually send anything
Also kill() with pid 0 should send to everyone in the same process group as the calling process.
This commit is contained in:
parent
8345f51a24
commit
005313df82
Notes:
sideshowbarker
2024-07-19 10:24:33 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/005313df823
@ -1740,6 +1740,7 @@ KResult Process::do_kill(Process& process, int signal)
|
||||
kprintf("%s(%u) attempted to send SIGKILL to ring 0 process %s(%u)\n", name().characters(), m_pid, process.name().characters(), process.pid());
|
||||
return KResult(-EPERM);
|
||||
}
|
||||
if (signal != 0)
|
||||
process.send_signal(signal, this);
|
||||
return KSuccess;
|
||||
}
|
||||
@ -1781,17 +1782,21 @@ int Process::sys$kill(pid_t pid, int signal)
|
||||
{
|
||||
if (signal < 0 || signal >= 32)
|
||||
return -EINVAL;
|
||||
if (pid <= 0) {
|
||||
if (pid == 0)
|
||||
return do_killpg(m_pgid, signal);
|
||||
if (pid < 0)
|
||||
return do_killpg(-pid, signal);
|
||||
}
|
||||
if (pid == -1) {
|
||||
// FIXME: Send to all processes.
|
||||
ASSERT(pid != -1);
|
||||
return -ENOTIMPL;
|
||||
}
|
||||
if (pid == m_pid) {
|
||||
// FIXME: If we ignore this signal anyway, we don't need to block here, right?
|
||||
if (signal == 0)
|
||||
return 0;
|
||||
if (!current->should_ignore_signal(signal)) {
|
||||
current->send_signal(signal, this);
|
||||
(void)current->block<Thread::SemiPermanentBlocker>(Thread::SemiPermanentBlocker::Reason::Signal);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
InterruptDisabler disabler;
|
||||
|
Loading…
Reference in New Issue
Block a user