mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
Kernel: Add support for the WSTOPPED flag to the waitpid() syscall.
This makes waitpid() return when a child process is stopped via a signal. Use this in Shell to catch stopped children and return control to the command line. :^) Fixes #298.
This commit is contained in:
parent
de03b72979
commit
3073ea7d84
6 changed files with 44 additions and 20 deletions
|
@ -83,14 +83,21 @@ bool Scheduler::pick_next()
|
|||
|
||||
if (thread.state() == Thread::BlockedWait) {
|
||||
process.for_each_child([&](Process& child) {
|
||||
if (!child.is_dead())
|
||||
return true;
|
||||
if (thread.waitee_pid() == -1 || thread.waitee_pid() == child.pid()) {
|
||||
thread.m_waitee_pid = child.pid();
|
||||
thread.unblock();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (thread.waitee_pid() != -1 && thread.waitee_pid() != child.pid())
|
||||
return IterationDecision::Continue;
|
||||
|
||||
bool child_exited = child.is_dead();
|
||||
bool child_stopped = child.main_thread().state() == Thread::State::Stopped;
|
||||
|
||||
bool wait_finished = ((thread.m_wait_options & WEXITED) && child_exited)
|
||||
|| ((thread.m_wait_options & WSTOPPED) && child_stopped);
|
||||
|
||||
if (!wait_finished)
|
||||
return IterationDecision::Continue;
|
||||
|
||||
thread.m_waitee_pid = child.pid();
|
||||
thread.unblock();
|
||||
return IterationDecision::Break;
|
||||
});
|
||||
return IterationDecision::Continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue