diff options
| -rw-r--r-- | src/ft_e_externs_pipes.c | 29 | 
1 files changed, 15 insertions, 14 deletions
| diff --git a/src/ft_e_externs_pipes.c b/src/ft_e_externs_pipes.c index d4d648d..a54e565 100644 --- a/src/ft_e_externs_pipes.c +++ b/src/ft_e_externs_pipes.c @@ -53,22 +53,23 @@ static void  	{  		/* TODO: handle fork failed */  	} -	if ((pid = fork()) == 0) +	else  	{ -		close(pipefd[1]); -		dup2(pipefd[0], STDIN_FILENO); -		ft_e_extern_child(fullpath[1], ptr->next->one, msh); -	} -	/* else */ -	/* { */ -		close(pipefd[0]); -		close(pipefd[1]); -		while (wait(&status) != pid) -			; -		while (wait(&status) != pid) -			; +		if ((pid = fork()) == 0) +		{ +			close(pipefd[1]); +			dup2(pipefd[0], STDIN_FILENO); +			ft_e_extern_child(fullpath[1], ptr->next->one, msh); +		} +		else +		{ +			close(pipefd[0]); +			close(pipefd[1]); +			waitpid(-1, &status, 0); +		} +		waitpid(-1, &status, 0);  		msh->ret = WEXITSTATUS(status); -	/* } */ +	}  }  void | 
