minishell/src/executor/executor_fork.c
whaffman ab72bd5bbb malloc_safe
- add freelist to minishell
- add t_minishell *minishell to all function calling malloc_free
- substituted all malloc calls but the first to malloc_safe
2025-02-25 14:54:17 +01:00

41 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* executor_fork.c :+: :+: */
/* +:+ */
/* By: willem <willem@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/12 21:24:52 by willem #+# #+# */
/* Updated: 2025/02/25 13:51:48 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "minishell.h"
pid_t executor_fork(t_minishell *minishell, t_command *command)
{
pid_t pid;
// int status;
pid = fork();
if (pid > 0)
{
if (command->fd_in != 0)
close(command->fd_in);
if (command->fd_out != 1)
close(command->fd_out);
// waitpid(pid, &status, 0);
// return (((status) & 0xff00) >> 8);
signal_init_parent();
}
else if (pid == 0)
{
signal_init_child();
executor_child(minishell, command);
exit(127);
}
else
perror("fork");
return (pid);
}