-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsigs.c
More file actions
41 lines (38 loc) · 674 Bytes
/
sigs.c
File metadata and controls
41 lines (38 loc) · 674 Bytes
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
#include "minishell.h"
void handler(int c)
{
write(1, "\n", 1);
print_prompt1();
g_global.fsignal = 1;
g_global.return_value = 1;
if (g_global.ffork != 1 && g_global.ret != NULL )
{
free(g_global.ret);
g_global.ret = NULL;
}
c++;
}
void handler2(int c)
{
if ((g_global.ret && ft_strlen(g_global.ret) > 0) || g_global.ffork == 1)
{
write(2, "Quit: ", 6);
fprintf(stderr, "%d", c);
write(2, "\n", 1);
if (g_global.ffork != 1)
exit(120);
}
c++;
}
void sigs(void)
{
signal(SIGTERM, SIG_IGN);
signal(SIGINT, handler);
signal(SIGQUIT, handler2);
if (g_global.fsignal == 0)
{
print_prompt1();
g_global.fsignal = 1;
}
g_global.ret = NULL;
}