aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--exec.cpp2
-rw-r--r--io.cpp6
-rw-r--r--io.h10
-rw-r--r--postfork.cpp8
4 files changed, 8 insertions, 18 deletions
diff --git a/exec.cpp b/exec.cpp
index 8d6cfe04..320bcdd4 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 61af4a9c..57ce43d3 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<const io_data_t> &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<io_data_t> &data) :
io_chain_t::io_chain_t() : std::vector<shared_ptr<io_data_t> >()
{
}
+
diff --git a/io.h b/io.h
index 894e4c28..112d7611 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<io_data_t> get_io_for_fd(int fd);
};
-/**
- Remove the specified io redirection from the chain
-*/
-void io_remove(io_chain_t &list, const shared_ptr<const io_data_t> &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 713e2247..80318c47 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_fd_t*>(io)->old_fd)
+ if (io->io_mode == IO_FD && io->fd == static_cast<const io_fd_t*>(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);
/*