From 92628a384b89dc6a9756240e4e934e91d8273d5d Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Sun, 13 Aug 2017 15:27:08 -0700 Subject: [PATCH] Revert "Retry setpgid in setup_child_process on EPERM" This reverts commit d6c4e66484957355d4985938ca30bc5d31ddc156. It was meant for the major branch. --- src/exec.cpp | 5 +++-- src/postfork.cpp | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index f0e1f6af8..ec6d299c8 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -935,10 +935,11 @@ void exec_job(parser_t &parser, job_t *j) { // output, so that we can truncate the file. Does not apply to /dev/null. bool must_fork = redirection_is_to_real_file(stdout_io.get()) || redirection_is_to_real_file(stderr_io.get()); - if (!must_fork && p->is_last_in_job) { + if (!must_fork) { //we are handling reads directly in the main loop. Make sure source is unblocked. - //Note that we may still end up forking. unblock_previous(); + } + if (!must_fork && p->is_last_in_job) { const bool stdout_is_to_buffer = stdout_io && stdout_io->io_mode == IO_BUFFER; const bool no_stdout_output = stdout_buffer.empty(); const bool no_stderr_output = stderr_buffer.empty(); diff --git a/src/postfork.cpp b/src/postfork.cpp index 1e6e9fd29..999324bd1 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -78,13 +78,7 @@ bool child_set_group(job_t *j, process_t *p) { if (j->pgid == -2) { j->pgid = p->pid; } - //retry on EPERM because there's no way that a child cannot join an existing progress group - //because we are SIGSTOPing the previous job in the chain. Sometimes we have to try a few - //times to get the kernel to see the new group. (Linux 4.4.0) int failure = setpgid(p->pid, j->pgid); - while (failure == -1 && errno == EPERM) { - debug_safe(2, "Retrying setpgid in child process"); - } // TODO: Figure out why we're testing whether the pgid is correct after attempting to // set it failed. This was added in commit 4e912ef8 from 2012-02-27. failure = failure && getpgid(p->pid) != j->pgid;