fix(connec_cmd_execute): do not execute more than one command per process

This commit is contained in:
Khaïs COLIN 2025-04-08 16:18:57 +02:00
parent 596b21fc2f
commit 204ed35ff4
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/07 10:38:55 by khais #+# #+# */ /* Created: 2025/04/07 10:38:55 by khais #+# #+# */
/* Updated: 2025/04/09 16:58:44 by khais ### ########.fr */ /* Updated: 2025/04/10 15:27:08 by khais ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -37,11 +37,17 @@ static void connec_pipe_cmd_execute(t_connec_cmd *cmd, t_minishell *app)
pid1 = fork(); pid1 = fork();
if (pid1 == 0) if (pid1 == 0)
cmd_execute(cmd->first, app); cmd_execute(cmd->first, app);
pid2 = fork(); else
if (pid2 == 0) {
cmd_execute(cmd->second, app); pid2 = fork();
do_waitpid(app, pid1); if (pid2 == 0)
do_waitpid(app, pid2); cmd_execute(cmd->second, app);
else
{
do_waitpid(app, pid1);
do_waitpid(app, pid2);
}
}
} }
void connec_cmd_execute(t_connec_cmd *cmd, t_minishell *app) void connec_cmd_execute(t_connec_cmd *cmd, t_minishell *app)