This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignals.c
53 lines (48 loc) · 1.46 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signals.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ebouvier <ebouvier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/01 13:31:06 by ebouvier #+# #+# */
/* Updated: 2023/09/04 14:51:29 by ebouvier ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
#include "minishell.h"
#include "signals.h"
int g_sigint = 0;
void sig_handler_minishell(int sig)
{
if (sig == SIGINT)
{
if (g_sigint == 0)
ft_dprintf(1, "\n");
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
else if (sig == SIGQUIT)
{
ft_dprintf(1, "\33[2K\r");
rl_on_new_line();
rl_redisplay();
}
}
void sig_handler_job(int sig)
{
if (sig == SIGINT)
{
ft_dprintf(1, "\n");
rl_replace_line("", 0);
rl_on_new_line();
}
}
void sig_handler_here_doc(int sig)
{
close_if(0);
if (sig == SIGINT)
g_sigint = 1;
ft_dprintf(2, "\n");
}