From d0ce2b4824c9b8a00ef838e6a3a2519db584640f Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Sun, 13 Aug 2017 15:26:03 -0700 Subject: [PATCH] Revert "Minor refactoring" This reverts commit 15da6f02032f8bfa6d2af333cf386250ca76d4f5. It was meant for the major branch. --- src/exec.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 97669ba6f..761705b80 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -632,8 +632,8 @@ void exec_job(parser_t &parser, job_t *j) { if (blocked_pid != -1) { debug(2, L"Unblocking process %d.\n", blocked_pid); kill(blocked_pid, SIGCONT); - blocked_pid = -1; } + blocked_pid = -1; }; // This is the io_streams we pass to internal builtins. @@ -1174,13 +1174,15 @@ void exec_job(parser_t &parser, job_t *j) { //no one awaits it. } //regardless of whether the child blocked or not: - //only once per job, and only once we've actually executed an external command - if ((child_spawned || child_forked) && !pgrp_set) { + if (child_spawned || child_forked) { //this should be called after waitpid if child_forked && pipes_to_next_command //it can be called at any time if child_spawned - set_child_group(j, p->pid); - //we can't rely on p->is_first_in_job because a builtin may have been the first - pgrp_set = true; + if (!pgrp_set) { + set_child_group(j, p->pid); + //only once per job, and only once we've executed an external command for real + //we can't rely on p->is_first_in_job because a builtin may have been the first + pgrp_set = true; + } } //if the command we ran _before_ this one was SIGSTOP'd to let this one catch up, unblock it now. //this must be after the wait_pid on the process we just started, if any.