-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
53 lines (48 loc) · 1.68 KB
/
utils.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
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gcarbone <gcarbone@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/20 18:52:41 by dlanotte #+# #+# */
/* Updated: 2021/07/26 17:44:30 by gcarbone ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/minishell.h"
void init(t_term *term, char **env)
{
char *level;
level = getenv("SHLVL");
term->type = getenv("TERM");
tcgetattr(0, &term->dconf);
ft_memcpy(&term->cconf, &term->dconf, sizeof(struct termios));
term->cconf.c_lflag &= ~(ECHO | ICANON);
term->cursor = 0;
term->env = table_dup(env);
open_history(term);
level = ft_itoa(ft_atoi(level) + 1);
ft_setenv("SHLVL", level, 1, term);
free(level);
}
static void intHandler(int signal)
{
if (signal == SIGINT)
{
if (!g_term->pid)
exit(1);
write(1, "\n", 1);
if (getpid() != g_term->pid)
return ;
graphic_hub(2, find_path());
free(g_term->input);
g_term->input = ft_strdup("");
g_term->cursor = 0;
g_term->last_status = 1;
}
}
void ft_signal_manager(void)
{
signal(SIGINT, intHandler);
signal(SIGQUIT, intHandler);
}