Example #1
0
static int	manage_child(t_fifo_elem *cur, t_sllist **myenv)
{
  if (cur->data.fd[IN])
    xdup2(cur->data.fd[IN], 0);
  if (cur->data.fd[OUT])
    xdup2(cur->data.fd[OUT], 1);
  if (cur->data.flag[ERR])
    xdup2(cur->data.fd[OUT], 2);
  execute_extern(cur->data.argv, myenv);
  return (EXIT_SUCCESS);
}
Example #2
0
int				execute_all(t_shell *sh, CMD *c, int pip_sh[2][2],
					int pip[2][2])
{
	int	status;

	if (!is_default_out(c->fd_out, c->list_out, c))
		dup2(pip[0][1], 1);
	if (!is_default_out(c->fd_error, c->list_out, c))
		dup2(pip[1][1], 2);
	close(pip[0][0]);
	close(pip[1][0]);
	close(pip_sh[0][1]);
	close(pip_sh[1][1]);
	status = execute_extern(sh, c, pip_sh[0][0], pip_sh[1][0]);
	close(pip_sh[0][0]);
	close(pip_sh[1][0]);
	close(pip[0][1]);
	close(pip[1][1]);
	return (status);
}