save the PID!

This commit is contained in:
Quinten Mennen 2025-03-05 17:34:24 +01:00
parent 727935ea08
commit 3cba7c5341
2 changed files with 7 additions and 4 deletions

View File

@ -18,6 +18,8 @@ int is_builtin(char *cmd)
"unset", "env", "exit", NULL};
int i;
if (cmd == NULL)
return (-1);
i = 0;
while (builtins[i])
{

View File

@ -34,12 +34,13 @@ static int execute_builtin(t_minishell *msh, t_command *cmd)
return (exit_status);
}
static void executor_execute_command(t_minishell *msh, t_command *cmd)
static int executor_execute_command(t_minishell *msh, t_command *cmd)
{
if (cmd->args[0] != NULL && is_builtin(cmd->args[0]) >= 0)
if (is_builtin(cmd->args[0]) >= 0)
msh->exit_status = execute_builtin(msh, cmd);
else if (cmd->args[0] != NULL)
executor_fork(msh, cmd);
return (executor_fork(msh, cmd));
return (0);
}
int executor_execute_pipeline(t_minishell *msh)
@ -55,7 +56,7 @@ int executor_execute_pipeline(t_minishell *msh)
last_pid = 0;
while (current)
{
executor_execute_command(msh, (t_command *)current->content);
last_pid = executor_execute_command(msh, (t_command *)current->content);
current = current->next;
}
if (last_pid != 0)