summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-27 21:20:58 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-27 21:21:48 +0100
commit8b4980489560a7cb2e7ad3cac75d037ebe1a9890 (patch)
tree2500564e23b3d3c2c0737e6be03463cc209666f3 /Kernel
parentf4302b58fb0877b921ac5fac7fa12b75263e8edc (diff)
downloadserenity-8b4980489560a7cb2e7ad3cac75d037ebe1a9890.zip
Kernel: sys$waitpid() only needs the waitee thread in the stopped case
If the waitee process is dead, we don't need to inspect the thread. This fixes an issue with sys$waitpid() failing before reap() since dead processes will have no remaining threads alive.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 3e849fb0d3..9ee629f083 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -2318,14 +2318,13 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
if (!waitee_process)
return -ECHILD;
- auto* waitee_thread = Thread::from_tid(waitee_pid);
- if (!waitee_thread)
- return -ECHILD;
-
ASSERT(waitee_process);
if (waitee_process->is_dead()) {
exit_status = reap(*waitee_process);
} else {
+ auto* waitee_thread = Thread::from_tid(waitee_pid);
+ if (!waitee_thread)
+ return -ECHILD;
ASSERT(waitee_thread->state() == Thread::State::Stopped);
exit_status = (waitee_thread->m_stop_signal << 8) | 0x7f;
}