mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(heredoc): Now displaying ^C again in heredoc when SIGINT caught
This commit is contained in:
parent
b7686df5a8
commit
7cd8d981e2
5 changed files with 27 additions and 7 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* here_doc_utils.c :+: :+: :+: */
|
/* here_doc_utils.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/02 14:36:33 by kcolin #+# #+# */
|
/* Created: 2025/05/02 14:36:33 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/05/05 11:33:36 by kcolin ### ########.fr */
|
/* Updated: 2025/05/05 12:04:34 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/02 11:53:53 by kcolin #+# #+# */
|
/* Created: 2025/05/02 11:53:53 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/05/02 13:10:24 by jguelen ### ########.fr */
|
/* Updated: 2025/05/02 17:38:40 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/05/02 12:16:37 by kcolin #+# #+# */
|
/* Created: 2025/05/02 12:16:37 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/05/02 13:01:42 by jguelen ### ########.fr */
|
/* Updated: 2025/05/05 12:03:56 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ int set_here_doc_mode_sig_handling(void)
|
||||||
ft_bzero(&sig_act, sizeof(struct sigaction));
|
ft_bzero(&sig_act, sizeof(struct sigaction));
|
||||||
if (sigemptyset(&sig_act.sa_mask) == -1)
|
if (sigemptyset(&sig_act.sa_mask) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
sig_act.sa_sigaction = &sig_cmd;
|
sig_act.sa_sigaction = &sig_heredoc;
|
||||||
sig_act.sa_flags |= SA_SIGINFO;
|
sig_act.sa_flags |= SA_SIGINFO;
|
||||||
if (sigaction(SIGINT, &sig_act, NULL) == -1)
|
if (sigaction(SIGINT, &sig_act, NULL) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/19 18:21:55 by jguelen #+# #+# */
|
/* Created: 2025/02/19 18:21:55 by jguelen #+# #+# */
|
||||||
/* Updated: 2025/05/02 13:01:49 by jguelen ### ########.fr */
|
/* Updated: 2025/05/05 12:03:51 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -28,5 +28,6 @@ extern int g_signum;
|
||||||
int set_interactive_mode_sig_handling(void);
|
int set_interactive_mode_sig_handling(void);
|
||||||
int set_exec_mode_sig_handling(void);
|
int set_exec_mode_sig_handling(void);
|
||||||
int set_here_doc_mode_sig_handling(void);
|
int set_here_doc_mode_sig_handling(void);
|
||||||
|
void sig_heredoc(int signum, siginfo_t *siginfo, void *context);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/17 12:01:39 by kcolin #+# #+# */
|
/* Created: 2025/04/17 12:01:39 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/05/02 13:01:15 by jguelen ### ########.fr */
|
/* Updated: 2025/05/05 12:03:03 by jguelen ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -52,3 +52,22 @@ void sig_cmd(int signum, siginfo_t *siginfo, void *context)
|
||||||
}
|
}
|
||||||
g_signum = signum;
|
g_signum = signum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sig_heredoc(int signum, siginfo_t *siginfo, void *context)
|
||||||
|
{
|
||||||
|
(void)context;
|
||||||
|
(void)siginfo;
|
||||||
|
if (signum == SIGQUIT)
|
||||||
|
{
|
||||||
|
ft_dprintf(STDERR_FILENO, "Quit (core dumped)\n");
|
||||||
|
}
|
||||||
|
else if (signum == SIGINT)
|
||||||
|
{
|
||||||
|
ft_dprintf(STDOUT_FILENO, "^C\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ft_printf("\n");
|
||||||
|
}
|
||||||
|
g_signum = signum;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue