(fix): problème avec le | qui bouclait à l'infini

This commit is contained in:
guamss 2023-06-30 18:54:46 +02:00
parent e68598e39a
commit da402bdb1f

View File

@ -77,10 +77,18 @@ int execute(cmd* input, lst** env)
{ {
dup2(input->fd_out, 1); dup2(input->fd_out, 1);
dup2(input->fd_in, 0); 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)); exitcode = execve(input->executable, input->args, get_env_str(env));
} }
else else
{ {
if (input->fd_in > 2)
close(input->fd_in);
if (input->fd_out > 2)
close(input->fd_out);
waitpid(pid, &exitcode, 0); waitpid(pid, &exitcode, 0);
} }
return exitcode; return exitcode;