summaryrefslogtreecommitdiff
path: root/Kernel/Scheduler.cpp
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-05-25 13:23:41 +0300
committerAndreas Kling <kling@serenityos.org>2020-05-25 12:38:37 +0200
commit431bbde6dfffcf51f48981255e0d04091cc9d0b1 (patch)
tree8c1830c921e5dd9183d849d62b8dc2776fd64d04 /Kernel/Scheduler.cpp
parent2c2ce5be64ad4e4bca0dc72165f2cebbbf6dabf6 (diff)
downloadserenity-431bbde6dfffcf51f48981255e0d04091cc9d0b1.zip
Kernel: Fix returning random children from waitid(WNOHANG)
In case WNOHANG was specified, we want to always set should_unblock to true (which we do since commit 4402207b983b6ad4e317ef5affa4a78f10903a26), not wait_finished -- the latter causes us to immediately return this child to our caller, which is not what we want -- perhaps we should return another child which has actually exited or stopped, or nobody at all. To avoid confusion, also rename wait_finished to fits_the_spec. This fixes service keepalive functionality in SystemServer.
Diffstat (limited to 'Kernel/Scheduler.cpp')
-rw-r--r--Kernel/Scheduler.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index 1c3f3b19fc..76156bd283 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -273,11 +273,10 @@ bool Thread::WaitBlocker::should_unblock(Thread& thread, time_t, long)
});
}
- bool wait_finished = ((m_wait_options & WEXITED) && child_exited)
- || ((m_wait_options & WSTOPPED) && child_stopped)
- || (m_wait_options & WNOHANG);
+ bool fits_the_spec = ((m_wait_options & WEXITED) && child_exited)
+ || ((m_wait_options & WSTOPPED) && child_stopped);
- if (!wait_finished)
+ if (!fits_the_spec)
return IterationDecision::Continue;
m_waitee_pid = child.pid();