mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
parent
1406d63b85
commit
6699a72e0e
3 changed files with 19 additions and 4 deletions
17
src/proc.cpp
17
src/proc.cpp
|
@ -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");
|
||||
|
|
|
@ -82,6 +82,9 @@ class proc_status_t {
|
|||
/// \return if we are stopped (as in SIGSTOP).
|
||||
bool stopped() const { return WIFSTOPPED(status_); }
|
||||
|
||||
/// \return if we are continued (as in SIGCONT).
|
||||
bool continued() const { return WIFCONTINUED(status_); }
|
||||
|
||||
/// \return if we exited normally (not a signal).
|
||||
bool normal_exited() const { return WIFEXITED(status_); }
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ expect_prompt
|
|||
send_line "jobs"
|
||||
expect_prompt "jobs: There are no jobs" {} unmatched { puts stderr $error_msg }
|
||||
|
||||
send_line "sleep .3 &; kill -STOP %1; kill -CONT %1; jobs | string match -r running; wait"
|
||||
expect_prompt "running" {} unmatched { puts stderr "continued job should be running: Fail" }
|
||||
|
||||
# return immediately when no jobs
|
||||
set error_msg "return immediately when no jobs: Fail"
|
||||
|
||||
|
|
Loading…
Reference in a new issue