diff options
author | Cheer Xiao <xiaqqaix@gmail.com> | 2013-01-16 11:55:57 +0800 |
---|---|---|
committer | Cheer Xiao <xiaqqaix@gmail.com> | 2013-01-17 15:55:06 +0800 |
commit | 57ef5289feb4f8551031cc1077df7c33be2180bb (patch) | |
tree | 4c42b39e0599adfeda8d33a494ddf7e2b06a63b5 /exec.cpp | |
parent | a63c0311bbd7ce2831a7b130f07b3a703d51201b (diff) |
Make is_input a member of io_pipe_t
Diffstat (limited to 'exec.cpp')
-rw-r--r-- | exec.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
@@ -571,20 +571,24 @@ void exec(parser_t &parser, job_t *j) { shared_ptr<io_data_t> &io = j->io.at(idx); - if ((io->io_mode == IO_BUFFER) && io->is_input) + if ((io->io_mode == IO_BUFFER)) { - /* - Input redirection - create a new gobetween process to take - care of buffering, save the redirection in input_redirect - */ - process_t *fake = new process_t(); - fake->type = INTERNAL_BUFFER; - fake->pipe_write_fd = 1; - j->first_process->pipe_read_fd = io->fd; - fake->next = j->first_process; - j->first_process = fake; - input_redirect = static_cast<const io_buffer_t *>(io.get()); - break; + CAST_INIT(io_buffer_t *, io_buffer, io.get()); + if (io_buffer->is_input) + { + /* + Input redirection - create a new gobetween process to take + care of buffering, save the redirection in input_redirect + */ + process_t *fake = new process_t(); + fake->type = INTERNAL_BUFFER; + fake->pipe_write_fd = 1; + j->first_process->pipe_read_fd = io->fd; + fake->next = j->first_process; + j->first_process = fake; + input_redirect = io_buffer; + break; + } } } @@ -615,12 +619,10 @@ void exec(parser_t &parser, job_t *j) } - shared_ptr<io_pipe_t> pipe_read(new io_pipe_t(0)); - pipe_read->is_input = 1; + shared_ptr<io_pipe_t> pipe_read(new io_pipe_t(0, true)); pipe_read->pipe_fd[0] = pipe_read->pipe_fd[1] = -1; - shared_ptr<io_pipe_t> pipe_write(new io_pipe_t(1)); - pipe_write->is_input = 0; + shared_ptr<io_pipe_t> pipe_write(new io_pipe_t(1, false)); pipe_write->pipe_fd[0] = pipe_write->pipe_fd[1] = -1; j->io.push_back(pipe_write); |