srcs/execution/execve.c
void        handle_execve(t_shell *sh, t_cmd *cmd, char *path)
{
    pid_t   pid;
    char    **ev;
    char    **av;

    tcsetattr(0, 0, &(sh->old_term));
    if ((pid = fork()) == -1)
        ft_fprintf(2, "minishell: fork: %s\n", strerror(errno));
    else if (pid > 0)
        parent_code(sh, cmd, pid);
    else
    {
        set_read_write_pipe(cmd);
        av = create_argv(cmd->token);
        ev = create_envp(sh->env);
        exec(sh, path, av, ev);
    }
    free(path);
    tcsetattr(0, 0, &(sh->new_term));
}
/*
** Sets terminal to canonical, forks parent process and sets up necessary pipe
** ends. Child constructs arguments and environment variables and execve's.
** Parents waits for child to terminate and saves its exit status.
*/
Sets terminal to canonical, forks parent process and sets up necessary pipe
ends. Child constructs arguments and environment variables and execve's.
Parents waits for child to terminate and saves its exit status.
Sets terminal to canonical forks parent process and sets up necessary pipe ends . Child constructs arguments and environment variables and execve ' s . Parents waits for child to terminate and saves its exit status .
void        handle_execve(t_shell *sh, t_cmd *cmd, char *path)
{
    pid_t   pid;
    char    **ev;
    char    **av;
    tcsetattr(0, 0, &(sh->old_term));
    if ((pid = fork()) == -1)
        ft_fprintf(2, "minishell: fork: %s\n", strerror(errno));
    else if (pid > 0)
        parent_code(sh, cmd, pid);
    else
    {
        set_read_write_pipe(cmd);
        av = create_argv(cmd->token);
        ev = create_envp(sh->env);
        exec(sh, path, av, ev);
    }
    free(path);
    tcsetattr(0, 0, &(sh->new_term));
}
void handle_execve ( t_shell * sh , t_cmd * cmd , char * path ) { pid_t pid ; char * * ev ; char * * av ; tcsetattr ( 0 , 0 , & ( sh -> old_term ) ) ; if ( ( pid = fork ( ) ) == -1 ) ft_fprintf ( 2 , " \n " , strerror ( errno ) ) ; else if ( pid > 0 ) parent_code ( sh , cmd , pid ) ; else { set_read_write_pipe ( cmd ) ; av = create_argv ( cmd -> token ) ; ev = create_envp ( sh -> env ) ; exec ( sh , path , av , ev ) ; } free ( path ) ; tcsetattr ( 0 , 0 , & ( sh -> new_term ) ) ; }
Sets terminal to canonical, forks parent process and sets up necessary pipe
ends.
Sets terminal to canonical forks parent process and sets up necessary pipe ends .