From 7e16ea3fe047f165e18a6d4489be30464a586140 Mon Sep 17 00:00:00 2001 From: Maieul BOYER Date: Sun, 13 Oct 2024 18:01:30 +0200 Subject: [PATCH] update: still smth to fix --- exec/src/run_ast/_spawn_cmd.c | 5 +++-- exec/src/run_ast/run_pipeline.c | 9 ++++++--- sources/main.c | 4 ++-- sources/signal_handler.c | 10 +++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/exec/src/run_ast/_spawn_cmd.c b/exec/src/run_ast/_spawn_cmd.c index bb35d4e5..17b00a96 100644 --- a/exec/src/run_ast/_spawn_cmd.c +++ b/exec/src/run_ast/_spawn_cmd.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/14 12:30:09 by maiboyer #+# #+# */ -/* Updated: 2024/10/13 17:32:14 by maiboyer ### ########.fr */ +/* Updated: 2024/10/13 17:59:35 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,6 +62,7 @@ t_error _spawn_cmd_and_run_end(\ struct s_ffree_state ffree; int status; + status = 0; ffree = (struct s_ffree_state){.state = state, .cmd_pipe = cmd_pipe}; info.forked_free_args = &ffree; info.forked_free = (void (*)(void *))_ffree_func; @@ -71,7 +72,7 @@ t_error _spawn_cmd_and_run_end(\ return (close_fd(cmd_pipe.input), out->exit = 127, ERROR); if (cmd_pipe.create_output || cmd_pipe.input != NULL) return (out->exit = -1, NO_ERROR); - if (waitpid(out->process.pid, &status, 0) == -1 && errno != ESRCH) + if (waitpid(out->process.pid, &status, 0) == -1 && errno != ECHILD) return (ERROR); if (WIFEXITED(status)) out->exit = WEXITSTATUS(status); diff --git a/exec/src/run_ast/run_pipeline.c b/exec/src/run_ast/run_pipeline.c index 1aa0ec52..c90acf79 100644 --- a/exec/src/run_ast/run_pipeline.c +++ b/exec/src/run_ast/run_pipeline.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/14 12:32:37 by maiboyer #+# #+# */ -/* Updated: 2024/10/13 13:58:31 by maiboyer ### ########.fr */ +/* Updated: 2024/10/13 18:01:06 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ #include "me/vec/vec_ast.h" #include "me/vec/vec_pid.h" #include +#include #include t_usize _pipeline_set_vars(\ @@ -47,9 +48,11 @@ void _wait_pipeline(t_vec_pid pids, t_state *state, t_pipeline_result *out) if (pids.len != 0) { + waitpid_status = 0; while (waitpid(pids.buffer[pids.len - 1], &waitpid_status, 0) < 0 \ - && errno != ESRCH) - ; + && errno != ECHILD) + if (errno == ECHILD) + waitpid_status = 0; while (waitpid(-1, NULL, 0) != -1) ; if (WIFEXITED(waitpid_status)) diff --git a/sources/main.c b/sources/main.c index 58a09ba1..fa90194b 100644 --- a/sources/main.c +++ b/sources/main.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */ -/* Updated: 2024/10/12 17:52:01 by rparodi ### ########.fr */ +/* Updated: 2024/10/13 17:55:56 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -94,7 +94,7 @@ t_error parse_str(t_state *state) if (ts_apply_passes(tokens, &tokens)) return (ERROR); if (yard(tokens, &ast)) - return ((void)printf("failed to ast build\n"), (ERROR)); + return (ERROR); if (ast.len != 1) return (ERROR); vec_ast_pop(&ast, &state->ast); diff --git a/sources/signal_handler.c b/sources/signal_handler.c index 3ac5c8f3..12de04c9 100644 --- a/sources/signal_handler.c +++ b/sources/signal_handler.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/02 13:22:14 by maiboyer #+# #+# */ -/* Updated: 2024/10/12 17:52:02 by rparodi ### ########.fr */ +/* Updated: 2024/10/13 17:56:04 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,9 +16,9 @@ t_error install_signal(void) { - if (signal(SIGINT, SIG_IGN)) - return (ERROR); - if (signal(SIGQUIT, SIG_IGN)) - return (ERROR); + //if (signal(SIGINT, SIG_IGN)) + // return (ERROR); + //if (signal(SIGQUIT, SIG_IGN)) + // return (ERROR); return (NO_ERROR); }