diff --git a/srcs/main.c b/srcs/main.c index cd07334..0c6be51 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -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); diff --git a/srcs/parser_hugo.c b/srcs/parser_hugo.c index 25fabc2..2c82367 100644 --- a/srcs/parser_hugo.c +++ b/srcs/parser_hugo.c @@ -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; }