diff options
| author | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-21 10:52:16 +0200 |
|---|---|---|
| committer | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-21 10:52:16 +0200 |
| commit | 12827ec90fca73861170b6f3730ff5031cce8cb6 (patch) | |
| tree | 1dafd8bc8d5f81c91ceb4bb9f6a699a817598943 /redes/exec.c | |
| parent | 92e28ef4f3c1689976fae2d99ae64bbfffedf179 (diff) | |
fix exec details
- piping seems to work
Diffstat (limited to 'redes/exec.c')
| -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) { |
