diff --git a/42sh/Makefile b/42sh/Makefile index 7d58c40b..846b7184 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -179,9 +179,9 @@ job_control/job_format_head.c\ job_control/job_free.c\ job_control/job_getprocess.c\ job_control/job_getrank.c\ +job_control/job_hup_all.c\ job_control/job_is_completed.c\ job_control/job_is_stopped.c\ -job_control/job_kill_all.c\ job_control/job_notify_change.c\ job_control/job_notify_new.c\ job_control/job_remove.c\ diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 08f66b66..78d034c5 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2017/03/17 23:10:35 by wescande ### ########.fr */ +/* Updated: 2017/03/20 11:38:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,7 +58,7 @@ void job_run(t_job *job, int foreground); int job_wait(int id); void job_remove(int id); void job_free(void *content, size_t content_size); -void job_kill_all(void); +void job_hup_all(void); int put_job_in_foreground(t_job *job, int cont); int put_job_in_background(t_job *job, int cont); @@ -79,7 +79,7 @@ void process_format(t_list **p, int firstp, int opts); ** Mapping pour afficher les process */ void pprint(t_process *p); -int pprint_subshell(t_process *p); +int pprint_subshell(t_process *p);; int pprint_brace(t_process *p); int pprint_while(t_process *p); int pprint_if(t_process *p); diff --git a/42sh/src/builtin/builtin_exit.c b/42sh/src/builtin/builtin_exit.c index d38bd167..f64c4a15 100644 --- a/42sh/src/builtin/builtin_exit.c +++ b/42sh/src/builtin/builtin_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ -/* Updated: 2017/03/18 15:41:42 by gwojda ### ########.fr */ +/* Updated: 2017/03/20 11:37:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,8 @@ int builtin_exit(const char *path, char *const av[], char *const envp[]) if (SH_HAS_JOBC(data_singleton()->opts) && jlist && !notified) { notified = 1; - ft_dprintf(2, "{red}%s: you have live jobs (running or suspended).{eoc}\n", SHELL_NAME); + ft_dprintf(2, "%s: you have live jobs (running or suspended)\n", + data_singleton()->argv[0]); return (0); } if (av && av[1]) @@ -35,6 +36,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[]) status = ft_atoi(ft_getenv(data_singleton()->env, "?")); if (SH_IS_INTERACTIVE(data_singleton()->opts)) tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes); + job_hup_all(); data_exit(); exit(status); return (0); diff --git a/42sh/src/exec/exec_reset.c b/42sh/src/exec/exec_reset.c index b83d6928..45e91663 100644 --- a/42sh/src/exec/exec_reset.c +++ b/42sh/src/exec/exec_reset.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */ -/* Updated: 2017/03/20 08:51:51 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:35:49 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,7 +30,7 @@ int exec_reset(void) exec->attrs = 0; exec->job.id = 0; exec->job.pgid = 0; - exec->job.attrs = 0; + exec->job.attrs = JOB_NOTIFIED; exec->job.first_process = NULL; tcgetattr(STDIN, &exec->job.tmodes); jobc->first_job = NULL; diff --git a/42sh/src/exec/process_set.c b/42sh/src/exec/process_set.c index b3f61ed8..69f451ff 100644 --- a/42sh/src/exec/process_set.c +++ b/42sh/src/exec/process_set.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:57:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:38:35 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redir_free.c b/42sh/src/exec/redir_free.c index 09665cd9..0e04cec2 100644 --- a/42sh/src/exec/redir_free.c +++ b/42sh/src/exec/redir_free.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/03 18:12:57 by ariard #+# #+# */ -/* Updated: 2017/03/18 18:59:57 by ariard ### ########.fr */ +/* Updated: 2017/03/20 11:39:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/builtin_jobs.c b/42sh/src/job_control/builtin_jobs.c index 3031cde0..dbae9068 100644 --- a/42sh/src/job_control/builtin_jobs.c +++ b/42sh/src/job_control/builtin_jobs.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */ -/* Updated: 2017/03/08 18:52:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:47:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_addprocess.c b/42sh/src/job_control/job_addprocess.c index 02181cb8..a72895c0 100644 --- a/42sh/src/job_control/job_addprocess.c +++ b/42sh/src/job_control/job_addprocess.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:57:09 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:32:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_free.c b/42sh/src/job_control/job_free.c index 7046cfe7..027c1676 100644 --- a/42sh/src/job_control/job_free.c +++ b/42sh/src/job_control/job_free.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ -/* Updated: 2017/01/09 13:22:16 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:39:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_kill_all.c b/42sh/src/job_control/job_hup_all.c similarity index 78% rename from 42sh/src/job_control/job_kill_all.c rename to 42sh/src/job_control/job_hup_all.c index ded01abd..0a4e238c 100644 --- a/42sh/src/job_control/job_kill_all.c +++ b/42sh/src/job_control/job_hup_all.c @@ -1,18 +1,18 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* job_kill_all.c :+: :+: :+: */ +/* job_hup_all.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/08 15:36:56 by jhalford #+# #+# */ -/* Updated: 2017/01/09 16:35:51 by jhalford ### ########.fr */ +/* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */ +/* Updated: 2017/03/20 11:37:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -void job_kill_all(void) +void job_hup_all(void) { t_jobc *jobc; t_list *jlist; @@ -23,7 +23,7 @@ void job_kill_all(void) while (jlist) { job = jlist->content; - kill(-job->pgid, SIGKILL); + kill(-job->pgid, SIGHUP); jlist = jlist->next; } } diff --git a/42sh/src/job_control/job_is_completed.c b/42sh/src/job_control/job_is_completed.c index 83bc6ecb..aa20bece 100644 --- a/42sh/src/job_control/job_is_completed.c +++ b/42sh/src/job_control/job_is_completed.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 15:10:20 by jhalford #+# #+# */ -/* Updated: 2017/03/20 11:10:14 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:30:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_is_stopped.c b/42sh/src/job_control/job_is_stopped.c index 45c0cb64..8d342c0f 100644 --- a/42sh/src/job_control/job_is_stopped.c +++ b/42sh/src/job_control/job_is_stopped.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 15:06:45 by jhalford #+# #+# */ -/* Updated: 2017/03/20 11:10:12 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:32:00 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,8 +25,8 @@ int job_is_stopped(int id) while (lst) { p = lst->content; - if (!(p->state == PROCESS_COMPLETED) - || !(p->state == PROCESS_SUSPENDED)) + if (!((p->state == PROCESS_COMPLETED) + || !(p->state == PROCESS_SUSPENDED))) return (0); lst = lst->next; } diff --git a/42sh/src/job_control/job_remove.c b/42sh/src/job_control/job_remove.c index 782aa632..e054c5c3 100644 --- a/42sh/src/job_control/job_remove.c +++ b/42sh/src/job_control/job_remove.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:20:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:40:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/mark_job_as_running.c b/42sh/src/job_control/mark_job_as_running.c index eb4b8623..0cf46b23 100644 --- a/42sh/src/job_control/mark_job_as_running.c +++ b/42sh/src/job_control/mark_job_as_running.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/08 14:40:40 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:56:42 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:33:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/process_format.c b/42sh/src/job_control/process_format.c index d6e54143..7fce0c80 100644 --- a/42sh/src/job_control/process_format.c +++ b/42sh/src/job_control/process_format.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:54:51 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:47:49 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/process_free.c b/42sh/src/job_control/process_free.c index 13e6aae7..29fab3f4 100644 --- a/42sh/src/job_control/process_free.c +++ b/42sh/src/job_control/process_free.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ -/* Updated: 2017/03/16 16:53:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:39:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index fcfb4611..5e1af3c5 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/20 11:30:08 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:30:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */