forked from muratkaanmesum/minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignal.c
37 lines (33 loc) · 1.28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* signal.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eablak <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/16 11:42:16 by eablak #+# #+# */
/* Updated: 2023/03/30 11:20:27 by eablak ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void ctrl_c(int sig)
{
(void)sig;
ioctl(STDIN_FILENO, TIOCSTI, "\n");
write(1, "\033[A", 3);
rl_replace_line("", 0);
rl_on_new_line();
rl_redisplay();
g_execute->last_exit_code = 1;
}
void ctrl_d(t_execute *execute)
{
int last_exec_code;
last_exec_code = execute->last_exit_code;
if (!execute->input)
{
printf("\nexit\n");
free_execute(execute);
exit(last_exec_code);
}
}