diff --git a/src/exec.cpp b/src/exec.cpp index b340b9590..047df6f71 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -23,8 +23,6 @@ #include #include #include -#include -#include #include "builtin.h" #include "common.h" @@ -495,7 +493,6 @@ void exec_job(parser_t &parser, job_t *j) { // // We are careful to set these to -1 when closed, so if we exit the loop abruptly, we can still // close them. - sem_t *chained_wait_prev = nullptr; int pipe_current_read = -1, pipe_current_write = -1, pipe_next_read = -1; for (std::unique_ptr &unique_p : j->processes) { if (exec_error) { @@ -514,14 +511,6 @@ void exec_job(parser_t &parser, job_t *j) { // See if we need a pipe. const bool pipes_to_next_command = !p->is_last_in_job; - //these semaphores will be used to make sure the first process lives long enough for the - //next process in the chain to open its handles, process group, etc. - //this child will block on this one, the next child will have to call sem_post against it. - sem_t *chained_wait_next = !pipes_to_next_command ? nullptr : (sem_t*)mmap(NULL, sizeof(sem_t*), PROT_READ|PROT_WRITE,MAP_SHARED|MAP_ANONYMOUS,-1, 0); - if (chained_wait_next != nullptr) { - sem_init(chained_wait_next, 1, 0); - } - // The pipes the current process write to and read from. Unfortunately these can't be just // allocated on the stack, since j->io wants shared_ptr. // @@ -1071,14 +1060,6 @@ 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(20 * 1000); - if (chained_wait_next != nullptr) { - debug(3, L"Waiting for next command in chain to start.\n"); - sem_wait(chained_wait_next); - sem_destroy(chained_wait_next); - munmap(chained_wait_next, sizeof(sem_t)); - } // This is the child process. p->pid = getpid(); setup_child_process(j, p, process_net_io_chain); @@ -1120,16 +1101,6 @@ void exec_job(parser_t &parser, job_t *j) { exec_close(pipe_current_write); pipe_current_write = -1; } - - //now that next command in the chain has been started, unblock the previous command - if (chained_wait_prev != nullptr) { - debug(3, L"Unblocking previous command in chain.\n"); - sem_post(chained_wait_prev); - munmap(chained_wait_prev, sizeof(sem_t)); - } - if (chained_wait_next != nullptr) { - chained_wait_prev = chained_wait_next; - } } // Clean up any file descriptors we left open.