-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
41 lines (34 loc) · 832 Bytes
/
main.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
/*
** EPITECH PROJECT, 2019
** PSU_minishell1_2018
** File description:
** something small
*/
#include "shell.h"
static const char * const builtin_aliases[] = {
"ls='ls --color=auto'",
0};
static void sighandle(int sig)
{
int st = 0;
if (sig != SIGINT && sig != SIGSTOP && sig != SIGQUIT)
return;
my_puts("");
if (waitpid(-1, &st, WNOHANG) == -1 && isatty(STDOUT_FILENO))
my_putstr(SHELL_PS1);
}
static void sig_init(void)
{
signal(SIGINT, sighandle);
signal(SIGSTOP, sighandle);
signal(SIGQUIT, sighandle);
}
int main(int ac, char **av, char **env)
{
sh_t sh = {mkdict(env), NULL, mkdict((char **)builtin_aliases), \
stdin, stdout, stderr, 0, false, SH_SHOWTREE};
sig_init();
if (ac > 1)
return noninteractive(ac, av, &sh);
return loop(&sh);
}