diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-09-09 23:37:38 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-10 11:20:22 +0200 |
commit | 927e2fc6bcf5a7149f9c5d1250f6e277860a2961 (patch) | |
tree | c269490d8708a4697da52df04faabad78b142890 /Shell | |
parent | c296bcc1d93e1172e9a9398f9ce9f982a15387f9 (diff) | |
download | serenity-927e2fc6bcf5a7149f9c5d1250f6e277860a2961.zip |
Shell: Do not reset the terminal attributes when command is run in bg
Also removes a FIXME that no longer applies.
Diffstat (limited to 'Shell')
-rw-r--r-- | Shell/AST.cpp | 4 | ||||
-rw-r--r-- | 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<Value> Background::run(RefPtr<Shell> 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<Job> 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<Job> 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()); |