static int do_cmd(char **cmd, int *i) { char **tab; int j; int ac; j = -1; if (cmd) while (cmd[++j]) { tab = ft_strsplit3(cmd[j], ' ', '\t', '"'); if (tab && *tab) { ac = cmd_exit(tab, i); if (*i == 2) { ft_freetab(&tab); return (ac); } ac = builtins(tab); if (ac < 0) launch_bin(tab, g_env, 0); } ft_freetab(&tab); } return (0); }
void exec_process(t_shell *sh, t_job *job, int *iofile) { t_parse *parse; parse = init_parse(sh, job->process->cmd); if (check_builtins(parse->argv[0])) { if (iofile[0] != 0) job->process->stdio[0] = iofile[0]; if (iofile[1] != 1) job->process->stdio[1] = iofile[1]; launch_builtin(sh, parse, job); } else if ((job->process->pid = fork()) == 0) { if (iofile[0] != 0) job->process->stdio[0] = iofile[0]; if (iofile[1] != 1) job->process->stdio[1] = iofile[1]; launch_bin(parse, job); } free_parse(&parse); if (iofile[0] != 0) close(iofile[0]); if (iofile[1] != 1) close(iofile[1]); }