-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignal_handler.c
45 lines (41 loc) · 1.3 KB
/
signal_handler.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signal_handler.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ynafiss <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/01 16:23:25 by azaher #+# #+# */
/* Updated: 2023/05/17 13:48:33 by ynafiss ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void handler(int signal)
{
(void)signal;
if (g_data.sigflag == 0)
{
write(1, "\n", 1);
rl_replace_line("", 0);
rl_on_new_line();
rl_redisplay();
}
}
void handel_quit(int sig)
{
ft_putstr_fd("^l'ndf \n", 2);
(void)sig;
}
void handle_signals(int i)
{
if (i == 0)
{
signal(SIGINT, handler);
signal(SIGQUIT, SIG_IGN);
}
else
{
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, handel_quit);
}
}