-
Notifications
You must be signed in to change notification settings - Fork 0
/
signal.c
49 lines (44 loc) · 1.53 KB
/
signal.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signal.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wonyang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/16 17:40:34 by wonyang #+# #+# */
/* Updated: 2023/01/16 18:46:22 by wonyang ### ########seoul.kr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <readline/readline.h>
#include <sys/ioctl.h>
#include "minishell.h"
extern t_global g_var;
void sigint_handler_prompt(int signo)
{
(void)signo;
g_var.status = 1;
ft_putchar_fd('\n', STDOUT_FILENO);
rl_on_new_line();
rl_replace_line("", 0);
rl_redisplay();
}
void sigint_handler_parent(int signo)
{
(void)signo;
g_var.status = 130;
ft_putchar_fd('\n', STDOUT_FILENO);
rl_on_new_line();
rl_replace_line("", 0);
}
void sigint_handler_heredoc(int signo)
{
(void)signo;
ioctl(STDIN_FILENO, TIOCSTI, "\n");
rl_on_new_line();
rl_replace_line("", 0);
g_var.is_signal = 1;
g_var.status = 1;
}