Exemplo n.º 1
0
int		exec_command(t_cmd *tmp, t_execution *exe)
{
  if (tmp->builtin == -1 &&
      execve(tmp->path, tmp->stock, exe->env->envp) == FAILURE)
    {
      exe->exit = FAILURE;
      return (ERRNO);
    }
  else
    exec_builtins(tmp, exe);
  return (SUCCESS);
}
Exemplo n.º 2
0
void		exec_cmd(t_param *param, t_cmd *cmd)
{
  int		pid;
  t_fd		save;

  if ((param->tty) && (param->debug))
    my_fprintf(2, "%[3]Exec command `%S' io [%d %d %d] %[]\n",
	       cmd->arg[0], cmd->in.fd, cmd->out.fd, cmd->err.fd);
  if (replace_tild(param, cmd))
    return;
  if (globing_substitution(cmd))
    return;
  SAVE_FD;
  DUP_FD;
  if (exec_builtins(param, cmd))
    cmd->pid = PID_BUILTIN;
  else if ((pid = fork()))
    cmd->pid = pid;
  else
    exec_cmd_low_level(param, cmd);
  RESTOR_FD;
  return;
}