diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-14 10:36:53 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-14 10:36:53 +0200 |
| commit | 26ddbd7146f65a2cf100713f422a9ab5b1890620 (patch) | |
| tree | 76daa703ee5ea4c3eafcbce0f8127ab5c92983ab /src/eval/pipe.c | |
| parent | ab1e32c348c649c1c7c8dad5922cfe1c0f11ac5d (diff) | |
| download | minishell-26ddbd7146f65a2cf100713f422a9ab5b1890620.tar.gz minishell-26ddbd7146f65a2cf100713f422a9ab5b1890620.tar.bz2 minishell-26ddbd7146f65a2cf100713f422a9ab5b1890620.zip | |
Changing ast related struct and fixing functions accordingly
Diffstat (limited to 'src/eval/pipe.c')
| -rw-r--r-- | src/eval/pipe.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/eval/pipe.c b/src/eval/pipe.c deleted file mode 100644 index 125c013..0000000 --- a/src/eval/pipe.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* pipe.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/04/01 17:05:58 by charles #+# #+# */ -/* Updated: 2020/04/01 17:05:59 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -/* -** \file pipe.c -** \brief Pipes setup -*/ - -#include "eval.h" - -/* -** \brief Setup STDIN and STDOUT pipe in the parent process -** \param cmd Command to setup -** \param pipe_in STDIN pipe -** \param pipe_out STDOUT pipe -** \return -1 on error, 0 otherwise -*/ - -int pipe_setup_parent(t_cmd *cmd, int pipe_in[2], int pipe_out[2]) -{ - if (cmd->in != NULL) - { - if ((pipe_in[PIPE_WRITE] = open(cmd->in, O_RDONLY)) < 0) - return (-1); - } - if (cmd->out != NULL) - { - if ((pipe_out[PIPE_READ] = open(cmd->out, - (cmd->is_append ? O_WRONLY : O_APPEND) | O_CREAT)) < 0) - return (-1); - } - return (0); -} - -/* -** \brief Setup STDIN and STDOUT pipe in the child process -** \param pipe_in STDIN pipe -** \param pipe_out STDOUT pipe -** \return -1 on error, 0 otherwise -*/ - -int pipe_setup_child(int pipe_in[2], int pipe_out[2]) -{ - if (pipe_in[PIPE_READ] != PIPE_CLOSED) - if (dup2(STDIN_FILENO, pipe_in[PIPE_READ]) == -1) - return (-1); - if (pipe_out[PIPE_WRITE] != PIPE_CLOSED) - if (dup2(STDOUT_FILENO, pipe_out[PIPE_WRITE]) == -1) - return (-1); - return (0); -} |
