fix(builtin/exit): prevent leak when calling exit in a subprocess

This commit is contained in:
Khaïs COLIN 2025-04-29 15:50:38 +02:00
parent 93f3ea7c66
commit 5ea55a9f9c
12 changed files with 65 additions and 58 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
/* Updated: 2025/04/29 15:10:35 by khais ### ########.fr */
/* Updated: 2025/04/29 15:47:27 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -97,7 +97,8 @@ static t_subprocess exec_external_cmd(t_simple_cmd *cmd, t_minishell *app,
t_subprocess simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app)
{
t_std_fds fds;
t_std_fds fds;
t_builtin_type type;
if (cmd == NULL)
return (PARENTPROCESS);
@ -111,7 +112,8 @@ t_subprocess simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app)
simple_cmd_execute_debug(cmd, app);
if (handle_redirections(cmd->redirections, app, &fds) == NULL)
return (PARENTPROCESS);
if (execute_builtin(cmd, app, &fds) == BUILTIN_INVALID)
return (exec_external_cmd(cmd, app, &fds));
return (PARENTPROCESS);
type = get_builtin(cmd);
if (type != BUILTIN_INVALID)
return (execute_builtin(cmd, app, &fds, type));
return (exec_external_cmd(cmd, app, &fds));
}