From 2bbd0ff867a1fe6ecae6cc29a8bd69eba8ef5e3b Mon Sep 17 00:00:00 2001 From: maix0 Date: Wed, 16 Oct 2024 22:12:45 +0200 Subject: [PATCH] The small fixes that were made in the corrections --- exec/src/run_ast/run_pipeline.c | 8 ++++---- exec/src/run_ast/run_subshell.c | 1 + sources/_helper_main.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/exec/src/run_ast/run_pipeline.c b/exec/src/run_ast/run_pipeline.c index 3154199f..9c00998e 100644 --- a/exec/src/run_ast/run_pipeline.c +++ b/exec/src/run_ast/run_pipeline.c @@ -59,7 +59,7 @@ void _wait_pipeline(t_vec_pid pids, t_state *state, t_pipeline_result *out) if (WIFEXITED(waitpid_status)) out->exit = WEXITSTATUS(waitpid_status); if (WIFSIGNALED(waitpid_status)) - out->exit = WTERMSIG(waitpid_status); + out->exit = WTERMSIG(waitpid_status) + 128; } else out->exit = 127; @@ -131,11 +131,11 @@ t_error run_pipeline(t_ast_pipeline *pipeline, t_state *state, cpipe.create_output = i < pipeline->statements.len - 1; child = pipeline->statements.buffer[i++]; if (child->kind == AST_COMMAND) - ret |= _pipeline_cmd(child, state, &cpipe, &pids); + ret = _pipeline_cmd(child, state, &cpipe, &pids); else if (child->kind == AST_SUBSHELL) - ret |= _subshell_cmd(child, state, &cpipe, &pids); + ret = _subshell_cmd(child, state, &cpipe, &pids); else - ret |= ((void)(printf("List in pipelines are unsupported,"\ + ret = ((void)(printf("List in pipelines are unsupported,"\ " use a subshell !\n")), ERROR); } return (_wait_pipeline(pids, state, out), ret); diff --git a/exec/src/run_ast/run_subshell.c b/exec/src/run_ast/run_subshell.c index 9f8c1498..87827d61 100644 --- a/exec/src/run_ast/run_subshell.c +++ b/exec/src/run_ast/run_subshell.c @@ -96,6 +96,7 @@ t_error run_subshell(t_ast_subshell *subshell, t_state *state, if (subshell == NULL || state == NULL || out == NULL) return (ERROR); mem_set_zero(&sinfo, sizeof(sinfo)); + mem_set_zero(&info, sizeof(info)); sinfo.state = state; if (_setup_redirection(&info, state, cmd_pipe, \ &subshell->suffixes_redirections)) diff --git a/sources/_helper_main.c b/sources/_helper_main.c index b26ac60d..f6fda511 100644 --- a/sources/_helper_main.c +++ b/sources/_helper_main.c @@ -41,7 +41,7 @@ t_error get_user_input(t_state *state) { errno = 0; lstate.pos = 0; - state->last_exit = 127; + state->last_exit = 130; string_clear(&lstate.buf); write_fd(lstate.output_fd, (void *)"^C\n", 3, NULL); line_refresh_line(&lstate);