From 284427a6dae00441384430aedda3703a57c44949 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Tue, 28 Dec 2021 14:16:06 -0800 Subject: [PATCH] Revert "Fix undefined behavior in closing a moved pipe" There is no undefined behavior in closing a moved pipe, since the move constructor simply sets the fd to -1, which is ignored by close(). The move constructor of autoclose_fd_t is "fully specified" (like unique_ptr). It's good practice to eagerly close pipes which may be inherited by child processes, since otherwise the writer may not get EPIPE correctly. Closing the pipe explicitly makes it clear that the pipe does not stay open across continue_job(). This reverts commit c014c23662f77498cd69b2c5e99ec9bdba9c9a3a. --- src/exec.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/exec.cpp b/src/exec.cpp index 55e65c622..c6658df4d 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -1100,6 +1100,7 @@ bool exec_job(parser_t &parser, const shared_ptr &j, const io_chain_t &bl } procs_launched += 1; } + pipe_next_read.close(); // If our pipeline was aborted before any process was successfully launched, then there is // nothing to reap, and we can perform an early return.