fix(exec): do now swallow prompt and io on incorrect command followed by redirection

This commit is contained in:
Khaïs COLIN 2025-04-28 15:04:47 +02:00
parent 65c1eb9d84
commit d4da91b62b
2 changed files with 20 additions and 8 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
/* Updated: 2025/04/28 14:42:13 by khais ### ########.fr */
/* Updated: 2025/04/28 15:57:23 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -81,14 +81,17 @@ static void exec_external_cmd(t_simple_cmd *cmd, t_minishell *app,
if (cmd->words == NULL)
return (restore_std_fds(fds));
exe = get_cmdpath(cmd->words->word->word, app);
if (exe == NULL)
return (command_not_found(cmd, app));
pid = fork();
if (pid == 0)
execute_subprocess(exe, cmd, app, fds);
if (exe != NULL)
{
pid = fork();
if (pid == 0)
execute_subprocess(exe, cmd, app, fds);
free(exe);
do_waitpid(app, pid);
}
restore_std_fds(fds);
free(exe);
do_waitpid(app, pid);
if (exe == NULL)
command_not_found(cmd, app);
}
void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app,