diff options
| author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-05-11 17:10:53 +0200 | 
|---|---|---|
| committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-05-11 17:10:53 +0200 | 
| commit | 3a7b348c39b2b28b5d530477b687182000cc70ed (patch) | |
| tree | e31fcc32121a31b05a2a503dd7be28b8736445d5 /src | |
| parent | Tryna pipe(2) (diff) | |
| download | 42-minishell-3a7b348c39b2b28b5d530477b687182000cc70ed.tar.gz 42-minishell-3a7b348c39b2b28b5d530477b687182000cc70ed.tar.bz2 42-minishell-3a7b348c39b2b28b5d530477b687182000cc70ed.tar.xz 42-minishell-3a7b348c39b2b28b5d530477b687182000cc70ed.tar.zst 42-minishell-3a7b348c39b2b28b5d530477b687182000cc70ed.zip | |
It's not pipin'
Diffstat (limited to '')
| -rw-r--r-- | src/ft_e_externs_pipes.c | 12 | 
1 files changed, 6 insertions, 6 deletions
| diff --git a/src/ft_e_externs_pipes.c b/src/ft_e_externs_pipes.c index a54e565..773905d 100644 --- a/src/ft_e_externs_pipes.c +++ b/src/ft_e_externs_pipes.c @@ -38,24 +38,24 @@ static void  				t_msh *msh)  {  	/* TODO: norme */ -	pid_t	pid; +	pid_t	pid[2];  	int32_t	pipefd[2];  	int32_t	status;  	pipe(pipefd); -	if ((pid = fork()) == 0) +	if ((pid[0] = fork()) == 0)  	{  		close(pipefd[0]);  		dup2(pipefd[1], STDOUT_FILENO);  		ft_e_extern_child(fullpath[0], ptr->one, msh);  	} -	else if (pid < 0) +	else if (pid[0] < 0)  	{  		/* TODO: handle fork failed */  	}  	else  	{ -		if ((pid = fork()) == 0) +		if ((pid[1] = fork()) == 0)  		{  			close(pipefd[1]);  			dup2(pipefd[0], STDIN_FILENO); @@ -65,9 +65,9 @@ static void  		{  			close(pipefd[0]);  			close(pipefd[1]); -			waitpid(-1, &status, 0); +			waitpid(pid[1], &status, 0);  		} -		waitpid(-1, &status, 0); +		waitpid(pid[0], &status, 0);  		msh->ret = WEXITSTATUS(status);  	}  } | 
