summaryrefslogtreecommitdiff
path: root/Shell
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-12-10 17:32:18 +0330
committerAndreas Kling <kling@serenityos.org>2020-12-10 16:20:39 +0100
commita2879f53c80b5b20b8cafd76176447ee0ca8f959 (patch)
treeabbb168fd346aa8bb8a964600c47bf3e916c8a0c /Shell
parent350b2c6d9e88b9f1d5e2cf2c01db2ffc64fa086e (diff)
downloadserenity-a2879f53c80b5b20b8cafd76176447ee0ca8f959.zip
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'.
Diffstat (limited to 'Shell')
-rw-r--r--Shell/Builtin.cpp1
-rw-r--r--Shell/Shell.cpp2
2 files changed, 3 insertions, 0 deletions
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<Job> 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())