From dfac81803b0da9fc1fd1d71f2f01abb1909dfc07 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Tue, 25 Jul 2017 23:04:57 -0500 Subject: [PATCH] Improved blocked prcoess comments, clarified job vs command chain --- src/exec.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index afa69b2a0..34657b5ce 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -1064,13 +1064,13 @@ void exec_job(parser_t &parser, job_t *j) { if (pid == 0) { // This is the child process. p->pid = getpid(); - // the process will be resumed by the shell when the next command in the - // chain is started setup_child_process(j, p, process_net_io_chain); - // start child processes that are part of a job in a stopped state + // Start child processes that are part of a chain in a stopped state // to ensure that they are still running when the next command in the // chain is started. + // The process will be resumed when the next command in the chain is started. + // Note that this may span multiple jobs, as jobs can read from each other. if (pipes_to_next_command) { kill(p->pid, SIGSTOP); } @@ -1081,7 +1081,7 @@ void exec_job(parser_t &parser, job_t *j) { } else { if (pipes_to_next_command) { //it actually blocked itself after forking above, but print in here for output - //synchronization and so we can assign blocked_pid in the correct address space + //synchronization & so we can assign command_blocked in the correct address space debug(2, L"Blocking process %d waiting for next command in chain.\n", pid); command_blocked = true; } @@ -1115,6 +1115,8 @@ void exec_job(parser_t &parser, job_t *j) { blocked_pid = -1; } if (command_blocked) { + //store the newly-blocked command's PID so that it can be SIGCONT'd once the next process + //in the chain is started. That may be in this job or in another job. blocked_pid = p->pid; }