Handle child receiving SIGCONT

Fixes #6818
This commit is contained in:
Johannes Altmanninger
2020-03-27 20:21:32 +01:00
parent 1406d63b85
commit 6699a72e0e
3 changed files with 19 additions and 4 deletions

View File

@@ -248,6 +248,8 @@ static void handle_child_status(process_t *proc, proc_status_t status) {
proc->status = status;
if (status.stopped()) {
proc->stopped = true;
} else if (status.continued()) {
proc->stopped = false;
} else {
proc->completed = true;
}
@@ -417,13 +419,20 @@ static void process_mark_finished_children(parser_t &parser, bool block_ok) {
} else if (proc->pid > 0) {
// Try reaping an external process.
int status = -1;
auto pid = waitpid(proc->pid, &status, WNOHANG | WUNTRACED);
auto pid = waitpid(proc->pid, &status, WNOHANG | WUNTRACED | WCONTINUED);
if (pid > 0) {
assert(pid == proc->pid && "Unexpcted waitpid() return");
handle_child_status(proc.get(), proc_status_t::from_waitpid(status));
FLOGF(proc_reap_external,
"Reaped external process '%ls' (pid %d, status %d)",
proc->argv0(), pid, proc->status.status_value());
if (proc->status.normal_exited() || proc->status.signal_exited()) {
FLOGF(proc_reap_external,
"Reaped external process '%ls' (pid %d, status %d)",
proc->argv0(), pid, proc->status.status_value());
} else {
assert(proc->status.stopped() || proc->status.continued());
FLOGF(proc_reap_external,
"External process '%ls' (pid %d, %s)",
proc->argv0(), pid, proc->status.stopped() ? "stopped" : "continued");
}
}
} else {
assert(0 && "Don't know how to reap this process");