From 927e2fc6bcf5a7149f9c5d1250f6e277860a2961 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Wed, 9 Sep 2020 23:37:38 +0430 Subject: [PATCH] Shell: Do not reset the terminal attributes when command is run in bg Also removes a FIXME that no longer applies. --- Shell/AST.cpp | 4 ---- Shell/Shell.cpp | 12 ++++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Shell/AST.cpp b/Shell/AST.cpp index 2b0a45d87a..e60472c2ab 100644 --- a/Shell/AST.cpp +++ b/Shell/AST.cpp @@ -348,10 +348,6 @@ void Background::dump(int level) const RefPtr Background::run(RefPtr shell) { - // FIXME: Currently this does not work correctly if `m_command.would_execute()', - // as it runs the node, which means nodes likes And and Or will evaluate - // all but their last subnode before yielding to this, causing a command - // like `foo && bar&` to effectively be `foo && (bar&)`. auto commands = m_command->to_lazy_evaluated_commands(shell); for (auto& command : commands) command.should_wait = false; diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index c3d1553d6b..a716e13533 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -541,16 +541,13 @@ RefPtr Shell::run_command(const AST::Command& command) if (child == 0) { close(sync_pipe[1]); - if (!m_is_subshell) - tcsetattr(0, TCSANOW, &default_termios); - m_is_subshell = true; m_pid = getpid(); Core::EventLoop::notify_forked(Core::EventLoop::ForkEvent::Child); jobs.clear(); if (apply_rewirings() == IterationDecision::Break) - return nullptr; + _exit(126); fds.collect(); @@ -564,8 +561,15 @@ RefPtr Shell::run_command(const AST::Command& command) dbg() << "Oof"; } +#ifdef SH_DEBUG + dbg() << "Synced up with parent, we're good to exec()"; +#endif + close(sync_pipe[0]); + if (!m_is_subshell && command.should_wait) + tcsetattr(0, TCSANOW, &default_termios); + if (command.should_immediately_execute_next) { ASSERT(command.argv.is_empty());