-
Notifications
You must be signed in to change notification settings - Fork 0
/
signal_handlers.c
63 lines (55 loc) · 1.9 KB
/
signal_handlers.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
61
62
63
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signal_handlers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aoizel <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 14:03:34 by aoizel #+# #+# */
/* Updated: 2024/01/22 11:05:49 by aoizel ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int main_signal_handlers(void)
{
struct sigaction action;
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
ft_bzero(&action, sizeof(action));
action.sa_handler = main_sig_int_handler;
action.sa_flags = SA_SIGINFO;
if (sigaction(SIGINT, &action, NULL))
return (-1);
return (0);
}
int heredoc_signal_handler(void)
{
struct sigaction action;
ft_bzero(&action, sizeof(action));
action.sa_handler = heredoc_sig_int_handler;
action.sa_flags = SA_SIGINFO;
if (sigaction(SIGINT, &action, NULL))
return (-1);
return (0);
}
void fork_signal_handler(void)
{
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
signal(SIGTERM, SIG_DFL);
}
int exec_signal_handler(void)
{
struct sigaction action;
ft_bzero(&action, sizeof(action));
action.sa_handler = exec_sig_int_handler;
action.sa_flags = SA_SIGINFO;
if (sigaction(SIGINT, &action, NULL))
return (-1);
signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
return (0);
}