Browse Source

[mod] use 'STDIN' and 'STDOUT' defines.

Moul 2 years ago
parent
commit
0325e6e6b2
1 changed files with 8 additions and 8 deletions
  1. 8 8
      src/heredoc.c

+ 8 - 8
src/heredoc.c

@@ -20,13 +20,13 @@ void	prompt_redirection_init(t_e *e, t_pipe *p, t_pipe_redir *t, t_pipe_redir *t
 	pipe(e->pipefd);
 	if (fork() == 0)
 	{
-		close(e->pipefd[0]);
-		ft_putstr_fd(txt, e->pipefd[1]);
+		close(e->pipefd[STDIN]);
+		ft_putstr_fd(txt, e->pipefd[STDOUT]);
 		ft_strdel(&txt);
 		exit(0);
 	}
 	wait(NULL);
-	close(e->pipefd[1]);
+	close(e->pipefd[STDOUT]);
 	prompt_redirection_exec(e, p, t, t2);
 }
 
@@ -43,8 +43,8 @@ void	prompt_redirection_exec(t_e *e, t_pipe *p, t_pipe_redir *t, t_pipe_redir *t
 {
 	int		stdfd;
 
-	stdfd = dup(0);
-	dup2(e->pipefd[0], 0);
+	stdfd = dup(STDIN);
+	dup2(e->pipefd[STDIN], STDIN);
 	if (t2 != NULL)
 		open_right_redirections(e, p, t2);
 	if (fork() == 0)
@@ -56,11 +56,11 @@ void	prompt_redirection_exec(t_e *e, t_pipe *p, t_pipe_redir *t, t_pipe_redir *t
 	if (t2 != NULL)
 	{
 		close(e->fd_file);
-		close(1);
+		close(STDOUT);
 		dup(e->fdout);
 	}
-	close(e->pipefd[0]);
-	close(0);
+	close(e->pipefd[STDIN]);
+	close(STDIN);
 	dup(stdfd);
 }