diff options
Diffstat (limited to 'redes')
| -rw-r--r-- | redes/exec.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/redes/exec.c b/redes/exec.c index 756eee6..afdf140 100644 --- a/redes/exec.c +++ b/redes/exec.c @@ -27,6 +27,11 @@ void execute_cmd(ExecutableCommand cmd, int* pgid) { dup2(fd_rd.to, fd_rd.redirected); } + for (int j = 0; j < cmd.open_fds.count; j++) { + int fd = *get_from_IntVec(&cmd.open_fds, j); + close(fd); + } + signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); signal(SIGTSTP, SIG_DFL); @@ -108,7 +113,12 @@ void execute_command_pipeline(Pipeline pipeline) { for (int i = 0; i < pipeline.count; i++) { PlCommand cmd = *get_from_Pipeline(&pipeline, i); ExecutableCommand exec_cmd = process_pl_command(cmd); + exec_cmd.stdin_fd = trunk_fd; + if (i > 0) { + push_to_IntVec(&exec_cmd.open_fds, trunk_fd); + } + exec_cmd.stdout_fd = STDOUT_FILENO; if (cmd.conn == CONN_PIPE) { |
