From a2879f53c80b5b20b8cafd76176447ee0ca8f959 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Thu, 10 Dec 2020 17:32:18 +0330 Subject: [PATCH] Shell: Restore the terminal PGID before printing out job status on exit This fixes the assert tripping when interrupting a foreground job. Also make `bg` mark the job as 'should announce exit'. --- Shell/Builtin.cpp | 1 + Shell/Shell.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Shell/Builtin.cpp b/Shell/Builtin.cpp index 9c2ab6d06f..a0a7c539c4 100644 --- a/Shell/Builtin.cpp +++ b/Shell/Builtin.cpp @@ -98,6 +98,7 @@ int Shell::builtin_bg(int argc, const char** argv) } job->set_running_in_background(true); + job->set_should_announce_exit(true); job->set_is_suspended(false); dbgln("Resuming {} ({})", job->pid(), job->cmd()); diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index 6d4123b21f..871c8df938 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -871,6 +871,8 @@ RefPtr Shell::run_command(const AST::Command& command) job->on_exit = [this](auto job) { if (!job->exited()) return; + + restore_ios(); if (job->is_running_in_background() && job->should_announce_exit()) warnln("Shell: Job {} ({}) exited\n", job->job_id(), job->cmd().characters()); else if (job->signaled() && job->should_announce_signal())