|
|
@ -6,7 +6,7 @@ |
|
|
|
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ |
|
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
|
/* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */ |
|
|
|
/* Updated: 2022/05/11 01:15:39 by narnaud@stude ### ########.fr */ |
|
|
|
/* Updated: 2022/05/11 01:24:29 by narnaud@stude ### ########.fr */ |
|
|
|
/* */ |
|
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
@ -72,18 +72,18 @@ int piper(t_datas *datas, t_command *cmd) |
|
|
|
close(cmd->fd[1]); |
|
|
|
if (cmd->fd[0]) |
|
|
|
close(cmd->fd[0]); |
|
|
|
printf("%s -ope: %d, pid: %d, fdin: %d, fdout: %d\n", cmd->argv[0], cmd->ope, pid, cmd->fd[0], cmd->fd[1]); |
|
|
|
if (DEBUG) |
|
|
|
printf("%s -ope: %d, pid: %d, fdin: %d, fdout: %d\n", cmd->argv[0], cmd->ope, pid, cmd->fd[0], cmd->fd[1]); |
|
|
|
if (cmd->ope == PIPE) |
|
|
|
pid = piper(datas, cmd->next); |
|
|
|
else |
|
|
|
{ |
|
|
|
waitpid(pid, &status, 0); |
|
|
|
exit_code = handle_status(datas, status); |
|
|
|
if (!cmd->next) |
|
|
|
datas->exit_code = exit_code; |
|
|
|
else if (cmd->next && ((cmd->ope == AND && !exit_code) \ |
|
|
|
if (cmd->next && ((cmd->ope == AND && !exit_code) \ |
|
|
|
|| (cmd->ope == OR && exit_code))) |
|
|
|
piper(datas, cmd->next); |
|
|
|
datas->exit_code = exit_code; |
|
|
|
} |
|
|
|
return (1); |
|
|
|
} |
|
|
|