int process_command_line(t_parser **parserp, t_env *envs, int *status, char *redir) { pid_t pid; t_parser *tmp; tmp = *parserp; if (strcmp(tmp->data, "|") == 0 && pipe(tmp->command->pipefd) == -1) return (-1); if (tmp->command->is_builtin == 1) return (select_builtin(tmp->command->new_argv, envs, status)); if ((pid = fork()) == 0) { if (test_redir(&tmp, redir) == -1 || test_pipe(tmp, *redir) == -1 || exec_cmd(tmp, envs) == -1) return (-1); } else if (pid > 0) { get_only_cmd_custom(parserp); (*parserp)->command->pid = pid; return (0); } else perror("Fork Error"); return (0); }
int sh_cmd_exec(t_data *st, t_parse *node) { int ret; ret = 0; if (node->val != NULL) { sh_split_cmd(st, node); if (node->range == -1) { if (select_builtin(st)) ret = sh_isnobuiltin(st); } else sh_call_op(st, node); } if (!(st->bina)) free(st->bina); if (!(st->cmd)) free(st->cmd); return (ret); }