-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignal.c
51 lines (45 loc) · 1.46 KB
/
signal.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signal.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bpisak-l <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/27 15:30:32 by bpisak-l #+# #+# */
/* Updated: 2024/07/29 12:28:07 by bpisak-l ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void handle_ctrl_c(int signum)
{
(void)signum;
set_exit_code(130);
write(1, "\n", 1);
rl_on_new_line();
rl_replace_line("", 1);
rl_redisplay();
}
void handle_heredoc_ctrl_c(int signum)
{
(void)signum;
set_exit_code(130);
write(1, "\n", 1);
rl_replace_line("", 1);
state()->heredocs_ok = 0;
close(0);
}
void init_signals(void)
{
signal(SIGINT, handle_ctrl_c);
signal(SIGQUIT, SIG_IGN);
}
void default_signals(void)
{
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
}
void let_signals_through(void)
{
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
}