-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_utils17.c
71 lines (65 loc) · 1.09 KB
/
ft_utils17.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
64
65
66
67
68
69
70
71
#include "minishell.h"
void handle_sigquit(int sig)
{
if (sig == SIGQUIT && g_global.g_status == 2)
{
printf("Quit: 3\n");
g_global.g_build_error_exec = 131;
}
else if (sig == SIGQUIT)
{
printf("\e[0K");
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
}
void handler(int sig)
{
(void)sig;
exit (130);
}
void init_lch(t_list *lst, char *str)
{
t_elem *new;
new = malloc(sizeof (t_elem));
if (!new)
exit(0);
new->data = ft_strdup(str);
new->prec = NULL;
new->next = NULL;
lst->first = new;
lst->last = new;
}
void signall(void)
{
if (g_global.g_kill_pid != 0)
{
kill(g_global.g_kill_pid, SIGTERM);
printf("\e[2D\e[0K\e[50D>\n");
}
else
exit (0);
rl_on_new_line();
rl_replace_line("", 0);
}
void handle_sigint(int sig)
{
(void)sig;
if (g_global.g_status == 0)
{
g_global.g_build_error_exec = 1;
printf("\e[0K\e[1K");
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
write(1, "\nMinishell% ", 12);
}
else if (g_global.g_status == 1)
signall();
else if (g_global.g_status == 2)
{
g_global.g_status = 100;
write(1, "\n", 1);
}
}