fix(sig): incorrect handling of C-\

Closes #197
This commit is contained in:
Khaïs COLIN 2025-05-02 12:21:05 +02:00
parent 52c33abb16
commit b7e48cca05
3 changed files with 14 additions and 10 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/04 19:55:22 by kcolin #+# #+# */ /* Created: 2025/04/04 19:55:22 by kcolin #+# #+# */
/* Updated: 2025/04/28 12:29:50 by kcolin ### ########.fr */ /* Updated: 2025/05/02 12:19:51 by kcolin ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,9 +29,5 @@ void do_waitpid(t_minishell *app, int pid)
if (WIFEXITED(wstatus)) if (WIFEXITED(wstatus))
app->last_return_value = WEXITSTATUS(wstatus); app->last_return_value = WEXITSTATUS(wstatus);
if (WIFSIGNALED(wstatus)) if (WIFSIGNALED(wstatus))
{
app->last_return_value = 128 + WTERMSIG(wstatus); app->last_return_value = 128 + WTERMSIG(wstatus);
if (WTERMSIG(wstatus) == SIGQUIT)
ft_dprintf(STDERR_FILENO, "Quit (core dumped)");
}
} }

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* sig.c :+: :+: :+: */ /* sig.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/20 10:26:05 by jguelen #+# #+# */ /* Created: 2025/05/02 12:16:37 by kcolin #+# #+# */
/* Updated: 2025/04/17 12:05:07 by kcolin ### ########.fr */ /* Updated: 2025/05/02 12:18:17 by kcolin ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -38,6 +38,7 @@ int set_interactive_mode_sig_handling(void)
return (-1); return (-1);
if (sigaction(SIGINT, &sig_act, NULL) == -1) if (sigaction(SIGINT, &sig_act, NULL) == -1)
return (-1); return (-1);
sig_act.sa_handler = SIG_IGN;
if (sigaction(SIGQUIT, &sig_act, NULL) == -1) if (sigaction(SIGQUIT, &sig_act, NULL) == -1)
return (-1); return (-1);
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/17 12:01:39 by kcolin #+# #+# */ /* Created: 2025/04/17 12:01:39 by kcolin #+# #+# */
/* Updated: 2025/05/02 12:03:49 by kcolin ### ########.fr */ /* Updated: 2025/05/02 12:20:24 by kcolin ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -48,6 +48,13 @@ void sig_cmd(int signum, siginfo_t *siginfo, void *context)
{ {
(void)context; (void)context;
(void)siginfo; (void)siginfo;
ft_printf("\n"); if (signum == SIGQUIT)
{
ft_dprintf(STDERR_FILENO, "Quit (core dumped)\n");
}
else
{
ft_printf("\n");
}
g_signum = signum; g_signum = signum;
} }