diff --git a/42sh/src/exec/mark_process_status.c b/42sh/src/exec/mark_process_status.c index 3c2ef390..807f1d95 100644 --- a/42sh/src/exec/mark_process_status.c +++ b/42sh/src/exec/mark_process_status.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ -/* Updated: 2017/03/16 23:00:36 by jhalford ### ########.fr */ +/* Updated: 2017/03/17 22:55:09 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,15 +19,18 @@ int mark_process_status(pid_t pid, int status) if ((plist = job_getprocess(pid))) { + DG("#######################"); p = plist->content; p->status = status; if (WIFSTOPPED(status)) { + DG("#######################"); p->attrs &= ~PROCESS_STATE_MASK; p->attrs |= PROCESS_SUSPENDED; } else { + DG("#######################"); p->attrs &= ~PROCESS_STATE_MASK; p->attrs |= PROCESS_COMPLETED; if (WIFSIGNALED(status) && DEBUG_MODE) diff --git a/42sh/src/exec/process_launch.c b/42sh/src/exec/process_launch.c index 932db515..20fe1e87 100644 --- a/42sh/src/exec/process_launch.c +++ b/42sh/src/exec/process_launch.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */ -/* Updated: 2017/03/17 20:31:20 by wescande ### ########.fr */ +/* Updated: 2017/03/17 22:49:31 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,19 +34,20 @@ int do_the_muther_forker(t_process *p) } else if (pid) return (pid); + DG("START OF FORK"); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); signal(SIGTSTP, SIG_DFL); signal(SIGTTIN, SIG_DFL); signal(SIGTTOU, SIG_DFL); signal(SIGCHLD, SIG_DFL); - data_singleton()->opts &= ~SH_INTERACTIVE; - data_singleton()->opts &= ~SH_OPTS_JOBC; if (process_redirect(p)) exit (1); process_setgroup(p, 0); process_setsig(); exec_reset(); + data_singleton()->opts &= ~SH_INTERACTIVE; + data_singleton()->opts &= ~SH_OPTS_JOBC; exit(p->map.launch(p)); } @@ -63,7 +64,7 @@ int process_launch(t_process *p) process_resetfds(p); return (1); } - DG("launcher forked!"); + DG("launcher forked! with : %d ", pid); p->pid = pid; process_setgroup(p, pid); if (p->fdin != STDIN) diff --git a/42sh/src/job-control/do_job_notification.c b/42sh/src/job-control/do_job_notification.c index 09ff6659..94e43f14 100644 --- a/42sh/src/job-control/do_job_notification.c +++ b/42sh/src/job-control/do_job_notification.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */ -/* Updated: 2017/03/16 18:35:01 by jhalford ### ########.fr */ +/* Updated: 2017/03/17 22:53:45 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,15 +27,19 @@ int do_job_notification(void) { j = jlist->content; jlist = jlist->next; + DG(); + if (job_is_completed(j->id)) + DG(); if (job_is_completed(j->id) || (job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED))) { + DG(); ret = 1; job_notify_change(j->id); j->attrs |= JOB_NOTIFIED; - if (job_is_completed(j->id)) - job_remove(j->id); + job_remove(j->id); } + DG(); } return (ret); } diff --git a/42sh/src/job-control/job_notify_change.c b/42sh/src/job-control/job_notify_change.c index 9535b95a..387d06a7 100644 --- a/42sh/src/job-control/job_notify_change.c +++ b/42sh/src/job-control/job_notify_change.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 15:04:03 by jhalford #+# #+# */ -/* Updated: 2017/03/08 17:18:20 by jhalford ### ########.fr */ +/* Updated: 2017/03/17 22:51:40 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,5 +19,6 @@ void job_notify_change(int id) jobc = &data_singleton()->jobc; job = ft_lst_find(jobc->first_job, &id, job_cmp_id)->content; - job_format(job, JOBS_OPTS_L); + if (job->attrs & JOB_BG) + job_format(job, JOBS_OPTS_L); } diff --git a/42sh/src/job-control/sigchld_handler.c b/42sh/src/job-control/sigchld_handler.c index 22d4c8a6..1f83749f 100644 --- a/42sh/src/job-control/sigchld_handler.c +++ b/42sh/src/job-control/sigchld_handler.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 17:37:56 by jhalford #+# #+# */ -/* Updated: 2017/03/08 17:21:34 by jhalford ### ########.fr */ +/* Updated: 2017/03/17 22:39:21 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,5 +14,7 @@ void sigchld_handler(int signo) { + DG("<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + do_job_notification(); (void)signo; } diff --git a/42sh/src/line-editing/ft_prompt.c b/42sh/src/line-editing/ft_prompt.c index bf6626f3..4bdae5e0 100644 --- a/42sh/src/line-editing/ft_prompt.c +++ b/42sh/src/line-editing/ft_prompt.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */ -/* Updated: 2017/03/16 16:43:35 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 22:41:13 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -107,7 +107,9 @@ void ft_prompt(void) ft_printf("\x1b[38;5;10m➜ "); ft_putstr("\x1b[38;5;361m"); ret += ft_currend_dir(); + signal(SIGCHLD, SIG_DFL); ret += ft_git_status(); + signal(SIGCHLD, sigchld_handler); ft_putstr("\033[22;37m"); data_singleton()->line.prompt_size = ret + 4; } diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 9915ee07..519c04ff 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/17 21:18:15 by wescande ### ########.fr */ +/* Updated: 2017/03/17 22:38:39 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -67,7 +67,7 @@ static int interactive_settings(void) signal(SIGTSTP, SIG_IGN); signal(SIGTTIN, SIG_IGN); signal(SIGTTOU, SIG_IGN); - signal(SIGCHLD, SIG_IGN); + signal(SIGCHLD, sigchld_handler); *shell_pgid = getpid(); if (setpgid(*shell_pgid, *shell_pgid)) {