Browse Source

fix: pipes

master
narnaud 3 years ago
parent
commit
8dd74802cb
  1. 7
      minishell.c

7
minishell.c

@ -6,7 +6,7 @@
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ /* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */ /* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */
/* Updated: 2022/05/03 15:50:18 by narnaud ### ########.fr */ /* Updated: 2022/05/03 16:25:14 by narnaud ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,7 +21,7 @@ int caller(t_command *cmd)
int status; int status;
if (cmd->next && cmd->fd[0] == 0 && cmd->next->fd[1] == 0) if (cmd->fd[1] == 0 && cmd->next && cmd->next->fd[0] == 0)
{ {
pipe(pip); pipe(pip);
cmd->fd[1] = pip[1]; cmd->fd[1] = pip[1];
@ -46,6 +46,9 @@ int caller(t_command *cmd)
if (cmd->next) if (cmd->next)
return (caller(cmd->next)); return (caller(cmd->next));
waitpid(pid, &status, 0); waitpid(pid, &status, 0);
if (cmd->fd[0])
close(cmd->fd[0]);
return (cmd_ret); return (cmd_ret);
} }

Loading…
Cancel
Save