il ne faut pas rouvrir le file descriptor, le man precise quil reste ouvert apres un exec, mais il etait seulement en read, pourtant il y a toujours une erreur, ce nest plus la meme
This commit is contained in:
@@ -30,8 +30,7 @@ void exec_cmd(char **envp, t_list *cmd_list)
|
||||
{
|
||||
if (cmd->fd_in != 0)
|
||||
close(cmd->fd_in);
|
||||
// if (cmd->fd_out != 1 && cmd->fd_redirect == 1)
|
||||
if (cmd->fd_out != 1)
|
||||
if (cmd->fd_out != 1 && cmd->fd_redirect == 1)
|
||||
close(cmd->fd_out);
|
||||
}
|
||||
while ((wpid = wait(&status)) > 0);
|
||||
|
||||
@@ -45,7 +45,7 @@ int handle_fd(char **input, int i, int fdin, t_cmd *cmd)
|
||||
{
|
||||
tmp[0] = '\0';
|
||||
tmp = ft_strtrim(tmp + 2, " "); // +2 for "> "
|
||||
cmd->fd_out = open(tmp, O_WRONLY | O_TRUNC);
|
||||
cmd->fd_out = open(tmp, O_RDWR | O_TRUNC);
|
||||
next_in = cmd->fd_out;
|
||||
cmd->fd_redirect = cmd->fd_out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user