Compare commits
No commits in common. "e2c43eb97317c9b02330ff2122c81dc310c1f878" and "0694b36a72a7843ce094e7655a6af73a51a93d14" have entirely different histories.
e2c43eb973
...
0694b36a72
@ -11,7 +11,6 @@
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "execution_private.h"
|
||||
#include <unistd.h>
|
||||
|
||||
static int ft_own_cmd(t_data *data, t_cmd *cmd)
|
||||
{
|
||||
@ -42,7 +41,7 @@ static int ft_own_cmd(t_data *data, t_cmd *cmd)
|
||||
return (return_code);
|
||||
}
|
||||
|
||||
static bool ft_executor(t_cmd *cmd, char **env)
|
||||
static int ft_executor(t_cmd *cmd, char **env)
|
||||
{
|
||||
if (cmd->fd_in[0] == -1 || cmd->fd_out[0] == -1 || cmd->executable == NULL)
|
||||
return (0);
|
||||
@ -53,15 +52,11 @@ static bool ft_executor(t_cmd *cmd, char **env)
|
||||
{
|
||||
dup2(cmd->fd_in[0], 0);
|
||||
dup2(cmd->fd_out[0], 1);
|
||||
if (cmd->fd_in[1] != -1)
|
||||
dup2(cmd->fd_in[1], 0);
|
||||
if (cmd->fd_out[1] != -1)
|
||||
dup2(cmd->fd_out[1], 1);
|
||||
ft_closer(cmd->fd_in);
|
||||
ft_closer(cmd->fd_out);
|
||||
if (cmd->fd_in[0] > 2)
|
||||
close(cmd->fd_in[0]);
|
||||
if (cmd->fd_out[0] > 2)
|
||||
close(cmd->fd_out[0]);
|
||||
execve(cmd->executable, cmd->args, env);
|
||||
ft_eprintf("minishell: permission denied: %s\n", cmd->executable);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
@ -83,9 +78,9 @@ static int ft_cmd_executor(t_data *data, t_cmd *cmd)
|
||||
if (env == NULL)
|
||||
return (1);
|
||||
exit_code = ft_executor(cmd, env);
|
||||
ft_freer_tab_ultimate(1, env);
|
||||
if (exit_code == 1)
|
||||
if (exit_code == -1)
|
||||
return (1);
|
||||
ft_freer_tab_ultimate(1, env);
|
||||
}
|
||||
if (ft_gen_exit_code(data))
|
||||
return (1);
|
||||
|
Loading…
Reference in New Issue
Block a user