From da402bdb1f1a5cc92c9381d54647f5d3ae2900dd Mon Sep 17 00:00:00 2001 From: guamss Date: Fri, 30 Jun 2023 18:54:46 +0200 Subject: [PATCH] =?UTF-8?q?(fix):=20probl=C3=A8me=20avec=20le=20|=20qui=20?= =?UTF-8?q?bouclait=20=C3=A0=20l'infini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/exec/exec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/exec/exec.c b/src/exec/exec.c index 7c6714b..3c6fc8a 100644 --- a/src/exec/exec.c +++ b/src/exec/exec.c @@ -77,10 +77,18 @@ int execute(cmd* input, lst** env) { dup2(input->fd_out, 1); dup2(input->fd_in, 0); + if (input->fd_in > 2) + close(input->fd_in); + if (input->fd_out > 2) + close(input->fd_out); exitcode = execve(input->executable, input->args, get_env_str(env)); } else { + if (input->fd_in > 2) + close(input->fd_in); + if (input->fd_out > 2) + close(input->fd_out); waitpid(pid, &exitcode, 0); } return exitcode;