From 063fb02ef46f76138a169eefb8b58752857f6c3e Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 12 Sep 2020 23:41:07 +0430 Subject: [PATCH] Shell: Move the first command in a pipeline to the pipeline pgid too This process is supposed to be the session leader of the pipeline process group, we can't *not* move it into that group :P --- Shell/Shell.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index a716e13533b..b3b406e0e5c 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -622,12 +622,14 @@ RefPtr Shell::run_command(const AST::Command& command) } pid_t pgid = is_first ? child : (command.pipeline ? command.pipeline->pgid : child); - if (!m_is_subshell && command.should_wait) { + if ((!m_is_subshell && command.should_wait) || command.pipeline) { if (setpgid(child, pgid) < 0) perror("setpgid"); - tcsetpgrp(STDOUT_FILENO, pgid); - tcsetpgrp(STDIN_FILENO, pgid); + if (!m_is_subshell) { + tcsetpgrp(STDOUT_FILENO, pgid); + tcsetpgrp(STDIN_FILENO, pgid); + } } while (write(sync_pipe[1], "x", 1) < 0) {