minishell/src/executor/executor_execute_pipeline.c
2025-02-26 16:17:07 +01:00

37 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* executor_execute_pipeline.c :+: :+: */
/* +:+ */
/* By: willem <willem@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/12 21:25:02 by willem #+# #+# */
/* Updated: 2025/02/26 16:10:39 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "minishell.h"
int executor_execute_pipeline(t_minishell *msh)
{
t_list *current;
t_command *command;
pid_t last_pid;
int exit_status;
executor_create_pipes(msh);
executor_create_redirects(msh);
current = msh->commands;
last_pid = 0;
while (current)
{
command = (t_command *)current->content;
command->environment = msh->environment;
last_pid = executor_fork(msh, command);
current = current->next;
}
waitpid(last_pid, &exit_status, 0);
signal_init_minishell();
return (((exit_status) & 0xff00) >> 8);
}