src/pipex.c
/**
 * Executes a function by taking the input as source and
 * storing the output in stdout. Forking the process.
 * 
 * @param cmd The full command, with args,
 * @param envp Enviroment pointer.
 */
Executes a function by taking the input as source and
storing the output in stdout. Forking the process.

@param cmd The full command, with args,
@param envp Enviroment pointer.
Executes a function by taking the input as source and storing the output in stdout . Forking the process . @param cmd The full command with args @param envp Enviroment pointer .
static void	ft_exec_child(char *cmd, char **envp)
{
	pid_t	pid;
	t_i32	fds[2];
	if (!ft_pipe(fds))
		ft_assert("Failed to create a pipe", EXIT_FAILURE);
	if (!ft_fork(&pid))
		ft_assert("A philospher dropped his fork...", EXIT_FAILURE);
	if (pid == 0)
	{
		close(fds[READ]);
		dup2(fds[WRITE], STDOUT_FILENO);
		ft_exec(cmd, envp);
	}
	else
	{
		close(fds[WRITE]);
		dup2(fds[READ], STDIN_FILENO);
		waitpid(pid, NULL, 0);
	}
}
static void ft_exec_child ( char * cmd , char * * envp ) { pid_t pid ; t_i32 fds [ 2 ] ; if ( ! ft_pipe ( fds ) ) ft_assert ( " " , EXIT_FAILURE ) ; if ( ! ft_fork ( & pid ) ) ft_assert ( " " , EXIT_FAILURE ) ; if ( pid == 0 ) { close ( fds [ READ ] ) ; dup2 ( fds [ WRITE ] , STDOUT_FILENO ) ; ft_exec ( cmd , envp ) ; } else { close ( fds [ WRITE ] ) ; dup2 ( fds [ READ ] , STDIN_FILENO ) ; waitpid ( pid , NULL , 0 ) ; } }
Executes a function by taking the input as source and
 storing the output in stdout.
Executes a function by taking the input as source and storing the output in stdout .