-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignals.c
60 lines (54 loc) · 1.55 KB
/
signals.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
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signals.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: acollin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/06 20:38:28 by acollin #+# #+# */
/* Updated: 2021/10/09 12:01:13 by acollin ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void sig_handler(int signum)
{
if (signum == SIGINT)
{
write(1, "\n", 1);
rl_replace_line("", 0);
rl_on_new_line();
rl_redisplay();
g_exit_status = 130;
}
}
void sig_handler3(int signum)
{
(void) signum;
if (signum == SIGINT)
{
write(1, "\n", 1);
g_exit_status = 130;
}
if (signum == SIGQUIT)
{
write(1, "Quit: 3\n", 8);
g_exit_status = 131;
}
}
void catch_heredoc_sig(void)
{
signal(SIGINT, sig_handler3);
signal(SIGQUIT, sig_handler3);
}
void sig_init(void)
{
rl_catch_signals = 0;
signal(SIGINT, sig_handler);
signal(SIGQUIT, SIG_IGN);
}
void interrupt_here_document(int signal)
{
(void)signal;
g_exit_status = 130;
exit(130);
}