-
Notifications
You must be signed in to change notification settings - Fork 0
/
signals.c
47 lines (43 loc) · 1.5 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signals.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akhalid <akhalid@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/28 22:45:58 by akhalid #+# #+# */
/* Updated: 2022/03/03 02:05:49 by akhalid ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void waiting_sigs(t_pipe *p)
{
g_all.pids_sig = 42;
while (waitpid(-1, &p->state, 0) > 0)
;
if (WIFEXITED(p->state))
g_all.exit_status = WEXITSTATUS(p->state);
else if (WIFSIGNALED(p->state))
{
if (WTERMSIG(p->state) == SIGQUIT)
write(2, "\\Quit: 3\n", ft_strlen("\\Quit: 3\n"));
g_all.exit_status = WTERMSIG(p->state) + 128;
}
if (g_all.exit_status == 141)
g_all.exit_status = 0;
g_all.pids_sig = 0;
}
void cntl_c(int sig)
{
int i;
i = sig;
if (g_all.pids_sig == 0)
{
g_all.exit_status = 1;
write(1, "\n", 1);
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
i = 0;
}
}