-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignals.c
More file actions
37 lines (32 loc) · 1.25 KB
/
Copy pathsignals.c
File metadata and controls
37 lines (32 loc) · 1.25 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signals.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpalomin <lpalomin@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/21 09:00:44 by lpalomin #+# #+# */
/* Updated: 2025/07/21 09:07:06 by lpalomin ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
volatile sig_atomic_t g_signal = 0;
void sigpipe_handler(int sig)
{
(void)sig;
exit(128 + SIGPIPE);
}
void sigint_handler(int sig)
{
g_signal = sig;
write(STDOUT_FILENO, "\n", 1);
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
void init_signals(void)
{
signal(SIGINT, sigint_handler);
signal(SIGQUIT, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
}