From 65ef17b62c545884fd1334c04ca24f53a09c92f2 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Tue, 14 Mar 2017 00:03:15 +0100 Subject: [PATCH] further subshell/brace launch re-design --- 42sh/src/exec/plaunch_brace.c | 33 +++++--------------------------- 42sh/src/exec/plaunch_subshell.c | 4 +++- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/42sh/src/exec/plaunch_brace.c b/42sh/src/exec/plaunch_brace.c index 66904681..d436c697 100644 --- a/42sh/src/exec/plaunch_brace.c +++ b/42sh/src/exec/plaunch_brace.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/13 19:09:30 by jhalford #+# #+# */ -/* Updated: 2017/03/13 23:59:04 by jhalford ### ########.fr */ +/* Updated: 2017/03/14 00:03:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,37 +14,14 @@ int plaunch_brace(t_process *p) { - pid_t pid; - - DG("plaunch_brace"); if (IS_PIPESINGLE(*p)) { if (process_redirect(p)) - { - DG("BRACE_GROUP redirection failed"); set_exitstatus(1, 1); - return (0); - } - ft_exec(&p->data.brace.content); + else + ft_exec(&p->data.brace.content); return (0); } - pid = fork(); - if (pid == 0) - { - DG("fork!"); - data_singleton()->opts &= ~SH_INTERACTIVE; - data_singleton()->opts &= ~SH_OPTS_JOBC; - if (process_redirect(p)) - exit (1); - process_setgroup(p, 0); - process_setsig(); - exec_reset(); - ft_exec(&p->data.brace.content); - exit(ft_atoi(ft_getenv(data_singleton()->env, "?"))); - } - else if (pid > 0) - return (pid); - else if (pid == -1) - ft_dprintf(2, "{red}%s: internal fork error{eoc}\n", SHELL_NAME); - return (0); + else + return (plaunch_subshell(p)) } diff --git a/42sh/src/exec/plaunch_subshell.c b/42sh/src/exec/plaunch_subshell.c index 9925dc51..de2b3f2f 100644 --- a/42sh/src/exec/plaunch_subshell.c +++ b/42sh/src/exec/plaunch_subshell.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 00:11:44 by wescande #+# #+# */ -/* Updated: 2017/03/13 23:59:10 by jhalford ### ########.fr */ +/* Updated: 2017/03/14 00:00:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,5 +31,7 @@ int plaunch_subshell(t_process *p) } else if (pid > 0) return (pid); + else if (pid == -1) + ft_dprintf(2, "{red}%s: internal fork error{eoc}\n", SHELL_NAME); return (0); }