summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-08 13:54:48 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-08 14:01:00 +0200
commit23eafdb8d6f1c866049dfe39281af42b68fe0d79 (patch)
treea230a01e3930e3085a2d95f81a358c246b2af9cd /Kernel
parentc983e966645d292594284c8fca29a4b4ae225e82 (diff)
downloadserenity-23eafdb8d6f1c866049dfe39281af42b68fe0d79.zip
Kernel: waitpid() should unblock and -ECHILD if SIG_IGN reaps child
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp3
-rw-r--r--Kernel/Scheduler.cpp5
2 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index cccea564dc..ec2fdb064f 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -1554,6 +1554,9 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
// NOTE: If waitee was -1, m_waitee_pid will have been filled in by the scheduler.
Process* waitee_process = Process::from_pid(waitee_pid);
+ if (!waitee_process)
+ return -ECHILD;
+
ASSERT(waitee_process);
if (waitee_process->is_dead()) {
exit_status = reap(*waitee_process);
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index 6e56b97b00..fe8c6459a6 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -195,6 +195,11 @@ Thread::WaitBlocker::WaitBlocker(int wait_options, pid_t& waitee_pid)
bool Thread::WaitBlocker::should_unblock(Thread& thread, time_t, long)
{
bool should_unblock = false;
+ if (m_waitee_pid != -1) {
+ auto* peer = Process::from_pid(m_waitee_pid);
+ if (!peer)
+ return true;
+ }
thread.process().for_each_child([&](Process& child) {
if (m_waitee_pid != -1 && m_waitee_pid != child.pid())
return IterationDecision::Continue;