From 47d8a7e8820382d3957f4bebbac79e5fd24d3d7f Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Tue, 25 Jul 2017 19:19:20 -0500 Subject: [PATCH] Explicitly nulling chained_wait_prev after munmap() --- src/exec.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/exec.cpp b/src/exec.cpp index b340b9590..03fc5687a 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -1071,8 +1071,9 @@ void exec_job(parser_t &parser, job_t *j) { { pid = execute_fork(false); if (pid == 0) { - // a hack that fixes any tcsetpgrp errors caused by race conditions + // usleep is a hack that fixes any tcsetpgrp errors caused by race conditions // usleep(20 * 1000); + // it should no longer be needed with the chained_wait_next code below. if (chained_wait_next != nullptr) { debug(3, L"Waiting for next command in chain to start.\n"); sem_wait(chained_wait_next); @@ -1126,6 +1127,7 @@ void exec_job(parser_t &parser, job_t *j) { debug(3, L"Unblocking previous command in chain.\n"); sem_post(chained_wait_prev); munmap(chained_wait_prev, sizeof(sem_t)); + chained_wait_prev = nullptr; } if (chained_wait_next != nullptr) { chained_wait_prev = chained_wait_next;