diff --git a/exec.cpp b/exec.cpp index a59cd55ed..428978115 100644 --- a/exec.cpp +++ b/exec.cpp @@ -1054,8 +1054,6 @@ void exec(parser_t &parser, job_t *j) p->completed = 1; } - io_buffer_destroy(io_buffer); - io_buffer.reset(); break; @@ -1455,7 +1453,6 @@ static int exec_subshell_internal(const wcstring &cmd, wcstring_list_t *lst) } } - io_buffer_destroy(io_buffer); return status; } diff --git a/io.cpp b/io.cpp index 37ca25a1c..6970a1c9d 100644 --- a/io.cpp +++ b/io.cpp @@ -161,19 +161,19 @@ io_buffer_t *io_buffer_create(bool is_input) return buffer_redirect; } -void io_buffer_destroy(const shared_ptr &io_buffer) +io_buffer_t::~io_buffer_t() { /** If this is an input buffer, then io_read_buffer will not have been called, and we need to close the output fd as well. */ - if (io_buffer->is_input) + if (is_input) { - exec_close(io_buffer->param1.pipe_fd[1]); + exec_close(param1.pipe_fd[1]); } - exec_close(io_buffer->param1.pipe_fd[0]); + exec_close(param1.pipe_fd[0]); /* Dont free fd for writing. This should already be free'd before diff --git a/io.h b/io.h index 4f0edd8ac..cc2a37667 100644 --- a/io.h +++ b/io.h @@ -128,6 +128,8 @@ public: { } + ~io_buffer_t(); + /** Function to create the output buffer */ void out_buffer_create() { @@ -199,11 +201,6 @@ shared_ptr io_chain_get(const io_chain_t &src, int fd); shared_ptr io_chain_get(io_chain_t &src, int fd); -/** - Free all resources used by a IO_BUFFER type io redirection. -*/ -void io_buffer_destroy(const shared_ptr &io_buffer); - /** Create a IO_BUFFER type io redirection, complete with a pipe and a vector for output. The default file descriptor used is 1 for diff --git a/reader.cpp b/reader.cpp index 693b220f5..56e9f8100 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1158,9 +1158,6 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector