-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsignal.c
55 lines (49 loc) · 1.43 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
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signal.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bmachado <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/02 13:30:33 by bmachado #+# #+# */
/* Updated: 2022/02/23 14:08:26 by bmachado ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void interrupt(int signal)
{
if (signal == SIGINT)
{
g_shell.error = 130;
printf("^C\n");
}
}
void quit(int signal)
{
if (signal == SIGQUIT)
{
g_shell.error = 131;
printf("minishell: quit process\n");
}
}
void redisplay(int signal)
{
if (signal == SIGINT)
{
g_shell.error = 130;
printf("\n");
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
}
void exec_signal(void)
{
signal(SIGINT, interrupt);
signal(SIGQUIT, quit);
}
void input_signal(void)
{
signal(SIGINT, redisplay);
signal(SIGQUIT, SIG_IGN);
}