From 33d963dad9c63495de9369e7a94a15764b76b3bb Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 30 Mar 2020 07:31:12 +0200 Subject: [PATCH] Make job a background job when its child process is stopped Fixes #6830 For some reason, with this change, typing "vi", Control-Z, and 2 x Control-D, results in the cursor not moving correctly, but this only seems to happen when starting fish from a fish that doesnt have this fix. I hope that is a temporary glitch. --- src/proc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/proc.cpp b/src/proc.cpp index 6bdfe15ac..18785ba03 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -398,7 +398,7 @@ static void process_mark_finished_children(parser_t &parser, bool block_ok) { // We got some changes. Since we last checked we received SIGCHLD, and or HUP/INT. // Update the hup/int generations and reap any reapable processes. - for (const auto &j : parser.jobs()) { + for (auto &j : parser.jobs()) { for (const auto &proc : j->processes) { if (auto mtopic = j->reap_topic_for_process(proc.get())) { // Update the signal hup/int gen. @@ -423,6 +423,9 @@ static void process_mark_finished_children(parser_t &parser, bool block_ok) { if (pid > 0) { assert(pid == proc->pid && "Unexpcted waitpid() return"); handle_child_status(proc.get(), proc_status_t::from_waitpid(status)); + if (proc->status.stopped()) { + j->mut_flags().foreground = 0; + } if (proc->status.normal_exited() || proc->status.signal_exited()) { FLOGF(proc_reap_external, "Reaped external process '%ls' (pid %d, status %d)",