diff --git a/exec.cpp b/exec.cpp index 8d6cfe043..320bcdd46 100644 --- a/exec.cpp +++ b/exec.cpp @@ -1185,7 +1185,7 @@ void exec_job(parser_t &parser, job_t *j) // Here we must have a non-NULL block_output_io_buffer assert(block_output_io_buffer.get() != NULL); - io_remove(process_net_io_chain, block_output_io_buffer); + process_net_io_chain.remove(block_output_io_buffer); block_output_io_buffer->read(); diff --git a/io.cpp b/io.cpp index 61af4a9c0..57ce43d3c 100644 --- a/io.cpp +++ b/io.cpp @@ -210,11 +210,6 @@ void io_chain_t::append(const io_chain_t &chain) this->insert(this->end(), chain.begin(), chain.end()); } -void io_remove(io_chain_t &list, const shared_ptr &element) -{ - list.remove(element); -} - void io_print(const io_chain_t &chain) { if (chain.empty()) @@ -288,3 +283,4 @@ io_chain_t::io_chain_t(const shared_ptr &data) : io_chain_t::io_chain_t() : std::vector >() { } + diff --git a/io.h b/io.h index 894e4c28c..112d7611c 100644 --- a/io.h +++ b/io.h @@ -63,8 +63,9 @@ public: class io_fd_t : public io_data_t { public: - /** fd to redirect specified fd to */ + /** fd to redirect specified fd to. For example, in 2>&1, old_fd is 1, and io_data_t::fd is 2 */ const int old_fd; + /** Whether to close old_fd */ const bool close_old; @@ -195,13 +196,6 @@ public: shared_ptr get_io_for_fd(int fd); }; -/** - Remove the specified io redirection from the chain -*/ -void io_remove(io_chain_t &list, const shared_ptr &element); - -/** Destroys an io_chain */ -void io_chain_destroy(io_chain_t &chain); /** Return the last io redirection in the chain for the specified file descriptor. diff --git a/postfork.cpp b/postfork.cpp index 713e2247c..80318c473 100644 --- a/postfork.cpp +++ b/postfork.cpp @@ -173,10 +173,10 @@ static int handle_child_io(const io_chain_t &io_chain) free_redirected_fds_from_pipes(io_chain); for (size_t idx = 0; idx < io_chain.size(); idx++) { - io_data_t *io = io_chain.at(idx).get(); + const io_data_t *io = io_chain.at(idx).get(); int tmp; - if (io->io_mode == IO_FD && io->fd == static_cast(io)->old_fd) + if (io->io_mode == IO_FD && io->fd == static_cast(io)->old_fd) { continue; } @@ -197,7 +197,7 @@ static int handle_child_io(const io_chain_t &io_chain) case IO_FILE: { // Here we definitely do not want to set CLO_EXEC because our child needs access - CAST_INIT(io_file_t *, io_file, io); + CAST_INIT(const io_file_t *, io_file, io); if ((tmp=open(io_file->filename_cstr, io_file->flags, OPEN_MASK))==-1) { @@ -257,7 +257,7 @@ static int handle_child_io(const io_chain_t &io_chain) case IO_BUFFER: case IO_PIPE: { - CAST_INIT(io_pipe_t *, io_pipe, io); + CAST_INIT(const io_pipe_t *, io_pipe, io); /* If write_pipe_idx is 0, it means we're connecting to the read end (first pipe fd). If it's 1, we're connecting to the write end (second pipe fd). */ unsigned int write_pipe_idx = (io_pipe->is_input ? 0 : 1); /*