From 638dbbaf9cb1fdbb8cb8b76243fa8117735e403a Mon Sep 17 00:00:00 2001 From: LuckyLaszlo Date: Tue, 21 Dec 2021 17:34:44 +0100 Subject: [PATCH] pipeline.c refactoring --- srcs/exec/pipeline.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/srcs/exec/pipeline.c b/srcs/exec/pipeline.c index 2a9ebcb..f429b40 100644 --- a/srcs/exec/pipeline.c +++ b/srcs/exec/pipeline.c @@ -26,17 +26,21 @@ int pipeline(t_all *c) return (0); if (!pipeline_find_access(pipeline, c->path)) return (0); - if (pipeline[0]->builtin_f && ft_2d_arrlen(pipeline) == 1) + if (ft_2d_arrlen(pipeline) > 1) + wait_subshell(pipeline_exec(pipeline, c)); + else { - if (!pipeline[0]->error) + if (pipeline[0]->error) + set_last_exit_status(pipeline[0]->error); + else if (pipeline[0]->builtin_f) { ret = simple_command_builtin(pipeline[0], c); if (ret != EXIT_SUCCESS) set_last_exit_status(ret); } + else + wait_subshell(pipeline_exec(pipeline, c)); } - else - wait_subshell(pipeline_exec(pipeline, c)); free_pipeline(&c->pipeline); return (1); }