no more atexit, we call builtin_exit at end of main or at ctrl D
This commit is contained in:
parent
21a2aca244
commit
7018cfc326
8 changed files with 14 additions and 32 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit bfc8ca207ab4d39f0140322c0f1d368137304a3c
|
||||
Subproject commit 6a2672a19268c6481525d9aaee5bd35722bbd75a
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/18 16:48:42 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/07 15:24:39 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
|
|||
ft_dprintf(2, "{red}%s: you have live jobs (running or suspended).{eoc}\n", SHELL_NAME);
|
||||
return (0);
|
||||
}
|
||||
if (av[1])
|
||||
if (av && av[1])
|
||||
status = ft_atoi(av[1]);
|
||||
else
|
||||
{
|
||||
|
|
@ -38,6 +38,9 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
|
|||
}
|
||||
ft_save_termios(-1);
|
||||
ft_free_hash_table();
|
||||
data_exit();
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);
|
||||
exit(status);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/18 13:27:16 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/07 15:20:46 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/17 15:36:49 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/07 15:18:24 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ int lexer_bquote(t_list **alst, t_lexer *lexer)
|
|||
push(&lexer->stack, lexer->state);
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
top_state = *(int*)pop(&lexer->stack)->content;
|
||||
top_state = pop(&lexer->stack);
|
||||
lexer->state = top_state == DQUOTE_BQUOTE ? DQUOTE : DEFAULT;
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/17 14:37:52 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/07 15:21:17 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/20 19:13:50 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/07 15:24:35 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -83,6 +83,7 @@ int main(int ac, char **av)
|
|||
t_data *data;
|
||||
|
||||
data = data_singleton();
|
||||
DG();DG();
|
||||
setlocale(LC_ALL, "");
|
||||
shell_init(ac, av);
|
||||
// DG("{inv}{bol}{gre}start of shell{eoc} JOBC is %s", SH_HAS_JOBC(data->opts)?"ON":"OFF");
|
||||
|
|
@ -93,5 +94,6 @@ int main(int ac, char **av)
|
|||
}
|
||||
else
|
||||
non_interactive_shell(shell_get_avdata());
|
||||
builtin_exit(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* shell_exit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 17:37:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/20 18:37:46 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void shell_exit(void)
|
||||
{
|
||||
// DG("shell_exit()");
|
||||
data_exit();
|
||||
if (SH_HAS_JOBC(data_singleton()->opts))
|
||||
job_kill_all();
|
||||
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/11 17:07:38 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/07 15:23:44 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,7 +21,6 @@ void shell_init(int ac, char **av)
|
|||
data = data_singleton();
|
||||
data->argc = ac;
|
||||
data->argv = ft_sstrdup(av);
|
||||
atexit(&shell_exit);
|
||||
shell_get_opts(ac, av);
|
||||
if (SH_IS_INTERACTIVE(data->opts))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue