From bf60c02fd3d1a8947b0e356ff0c491fb80305598 Mon Sep 17 00:00:00 2001 From: Adam Joly Date: Tue, 16 Jul 2024 14:41:03 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20fixed?= =?UTF-8?q?=20some=20bullshit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/error_msg.h | 4 +++- src/exec/exec_split_cmd.c | 6 +++-- src/exec/sig.c | 36 ++++++++++++++++++++++++++++ src/exec/utils_exec_2.c | 15 +----------- src/main.c | 3 ++- src/parsing/check_error/send_error.c | 4 +++- 6 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 src/exec/sig.c diff --git a/include/error_msg.h b/include/error_msg.h index edf8302..6b5cebc 100644 --- a/include/error_msg.h +++ b/include/error_msg.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/20 20:25:06 by adjoly #+# #+# */ -/* Updated: 2024/07/16 14:20:19 by adjoly ### ########.fr */ +/* Updated: 2024/07/16 14:32:44 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,4 +31,6 @@ char *get_program_name(char *argv_one); bool send_error_parsing(char *msg); bool check_space(char *rl); +//free(*get_rl(NULL)); + #endif diff --git a/src/exec/exec_split_cmd.c b/src/exec/exec_split_cmd.c index 7aab704..42eb18e 100644 --- a/src/exec/exec_split_cmd.c +++ b/src/exec/exec_split_cmd.c @@ -6,7 +6,7 @@ /* By: mmoussou next) return (exec_pipe_unforked(exec, list_cmd, env)); while (list_cmd->next) @@ -110,7 +112,7 @@ t_exec exec_pipe(t_exec exec, t_list *list_cmd, t_env *env) } exec.status = exec_fork_cmd(list_cmd->content, exec.env_array, \ env, exec.pipe_fd); - __sig(exec.status); + __sig2(exec.status); __close(list_cmd->content); return (exec); } diff --git a/src/exec/sig.c b/src/exec/sig.c new file mode 100644 index 0000000..8b401db --- /dev/null +++ b/src/exec/sig.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* sig.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/07/16 14:38:11 by adjoly #+# #+# */ +/* Updated: 2024/07/16 14:38:58 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +void ign(int signal) +{ + (void) signal; +} + +void __sig2(int status) +{ + if (WIFSIGNALED(status) && WTERMSIG(status) == SIGQUIT) + { + get_exit_code(131); + if (WCOREDUMP(status)) + ft_putendl_fd("Quit (core dumped)", 2); + else + ft_putendl_fd("Quit", 2); + } +} + +void __sig(void) +{ + signal(SIGQUIT, ign); + signal(SIGINT, ign); +} diff --git a/src/exec/utils_exec_2.c b/src/exec/utils_exec_2.c index d147762..9b9bbd2 100644 --- a/src/exec/utils_exec_2.c +++ b/src/exec/utils_exec_2.c @@ -6,7 +6,7 @@ /* By: mmoussou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/28 18:09:49 by adjoly #+# #+# */ -/* Updated: 2024/07/03 16:15:52 by adjoly ### ########.fr */ +/* Updated: 2024/07/16 14:26:39 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +#include "minishell.h" char *get_program_name(char *argv_one) { @@ -26,5 +27,6 @@ bool send_error_parsing(char *msg) ft_putstr_fd(get_program_name(NULL), STDERR_FILENO); ft_putstr_fd(": Error: ", STDERR_FILENO); ft_putendl_fd(msg, STDERR_FILENO); + get_exit_code(2); return (true); }