-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsig.c
More file actions
52 lines (45 loc) · 1.57 KB
/
sig.c
File metadata and controls
52 lines (45 loc) · 1.57 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sig.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: elavrich <elavrich@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/07 20:53:04 by elavrich #+# #+# */
/* Updated: 2025/07/27 22:44:08 by elavrich ### ########.fr */
/* */
/* ************************************************************************** */
#include "Minishell.h"
void setup_shell_signals(void)
{
struct sigaction sa;
sa.sa_handler = handle_sigint_prompt;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, NULL);
signal(SIGQUIT, SIG_IGN);
}
void handle_sigint_prompt(int sig)
{
(void)sig;
rl_replace_line("", 0);
write(1, "\n", 1);
rl_on_new_line();
rl_redisplay();
}
//maybe not needed
// void setup_heredoc_signals(void)
// {
// struct sigaction sa;
// sa.sa_handler = handle_sigint_heredoc;
// sa.sa_flags = 0;
// sigemptyset(&sa.sa_mask);
// sigaction(SIGINT, &sa, NULL);
// signal(SIGQUIT, SIG_IGN);
// }
// void handle_sigint_heredoc(int sig)
// {
// (void)sig;
// write(1, "\n", 1);
// _exit(130);
// }