Просмотр исходного кода

Shell: Silence TCSETPGRP errors when not interactive

AnotherTest 4 лет назад
Родитель
Сommit
48a1f7e55c
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      Shell/Shell.cpp

+ 3 - 3
Shell/Shell.cpp

@@ -817,13 +817,13 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
 
 
     pid_t pgid = is_first ? child : (command.pipeline ? command.pipeline->pgid : child);
     pid_t pgid = is_first ? child : (command.pipeline ? command.pipeline->pgid : child);
     if ((!m_is_subshell && command.should_wait) || command.pipeline) {
     if ((!m_is_subshell && command.should_wait) || command.pipeline) {
-        if (setpgid(child, pgid) < 0)
+        if (setpgid(child, pgid) < 0 && m_is_interactive)
             perror("setpgid");
             perror("setpgid");
 
 
         if (!m_is_subshell) {
         if (!m_is_subshell) {
-            if (tcsetpgrp(STDOUT_FILENO, pgid) != 0)
+            if (tcsetpgrp(STDOUT_FILENO, pgid) != 0 && m_is_interactive)
                 perror("tcsetpgrp(OUT)");
                 perror("tcsetpgrp(OUT)");
-            if (tcsetpgrp(STDIN_FILENO, pgid) != 0)
+            if (tcsetpgrp(STDIN_FILENO, pgid) != 0 && m_is_interactive)
                 perror("tcsetpgrp(IN)");
                 perror("tcsetpgrp(IN)");
         }
         }
     }
     }