diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 5c01cda8..b3346742 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/01/09 15:57:08 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:22:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index b7147f44..f83713c0 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/01/09 14:05:43 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:23:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,7 +52,7 @@ void job_update_rank(void); int do_job_notification(void); void job_notify_new(t_job *job); -void job_notify_change(int id, int status); +void job_notify_change(int id); void job_format(t_job *j, int rank[2], int opts); void job_format_head(t_job *j, int rank[2]); @@ -71,7 +71,6 @@ void job_kill_all(void); int put_job_in_foreground(t_job *job, int cont); int put_job_in_background(t_job *job, int cont); - int job_cmp_pid(t_job *job, pid_t *pid); int job_cmp_id(t_job *job, int *id); void job_getrank(int (*rank)[2]); diff --git a/42sh/src/builtin/builtin_exit.c b/42sh/src/builtin/builtin_exit.c index 9fd927a8..80148cb8 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/01/08 16:00:21 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:25:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_pipe.c b/42sh/src/exec/exec_pipe.c index 2907c020..8e777ae1 100644 --- a/42sh/src/exec/exec_pipe.c +++ b/42sh/src/exec/exec_pipe.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */ -/* Updated: 2017/01/09 15:56:40 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:19:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,7 +39,7 @@ int exec_pipe(t_btree **ast) if (start) p->attributes |= PROCESS_PIPESTART; - close(p->fdin); + close(fds[PIPE_READ]); p->fdin = STDIN; btree_delone(ast, &ast_free); return (0); diff --git a/42sh/src/job-control/builtin_jobs.c b/42sh/src/job-control/builtin_jobs.c index 032e0a47..8ce060dc 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/01/09 14:05:27 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:20:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/do_job_notification.c b/42sh/src/job-control/do_job_notification.c index 80db0521..98db5d4d 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/01/08 14:00:23 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:24:22 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,17 +26,17 @@ int do_job_notification(void) while (jlist) { j = jlist->content; - DG("checking job [%i]", j->id); + DG("checking [%i]", j->id); if (job_is_completed(j->id)) { ret = 1; - job_notify_change(j->id, 0); + job_notify_change(j->id); job_remove(j->id); } else if (job_is_stopped(j->id) && !(j->attributes & JOB_NOTIFIED)) { ret = 1; - job_notify_change(j->id, -1); + job_notify_change(j->id); j->attributes |= JOB_NOTIFIED; } jlist = jlist->next; diff --git a/42sh/src/job-control/job_kill_all.c b/42sh/src/job-control/job_kill_all.c index 11f343a7..158b716a 100644 --- a/42sh/src/job-control/job_kill_all.c +++ b/42sh/src/job-control/job_kill_all.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/08 15:36:56 by jhalford #+# #+# */ -/* Updated: 2017/01/08 15:44:07 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:25:25 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/job_notify_change.c b/42sh/src/job-control/job_notify_change.c index 8a99d535..d1e4a292 100644 --- a/42sh/src/job-control/job_notify_change.c +++ b/42sh/src/job-control/job_notify_change.c @@ -6,53 +6,20 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 15:04:03 by jhalford #+# #+# */ -/* Updated: 2017/01/09 12:39:33 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:24:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "job_control.h" -void job_notify_change(int id, int status) +void job_notify_change(int id) { t_job *job; t_jobc *jobc; - t_list *plist; - t_process *p; - char rank; + int rank[2]; - rank = ' '; jobc = &data_singleton()->jobc; - job = jobc->first_job->content; - if (id == job->id) - rank = '+'; - else if (jobc->first_job->next) - { - job = jobc->first_job->next->content; - if (id == job->id) - rank = '-'; - } - ft_printf("{mag}[%i] %c ", id, rank); job = ft_lst_find(jobc->first_job, &id, job_cmp_id)->content; - if (status == -1) - ft_printf("{red}stopped{mag}"); - else - { - plist = job->first_process; - p = ft_lstlast(job->first_process)->content; - if (p->status == 0) - ft_printf("{gre}done{mag}"); - else - ft_printf("{red}exit %i{mag}", p->status); - } - ft_printf("\t "); - plist = job->first_process; - while (plist) - { - p = plist->content; - ft_sstrprint(p->av, ' '); - if (plist->next) - ft_printf(" |"); - plist = plist->next; - } - ft_printf("{eoc}\n"); + job_getrank(&rank); + job_format(job, rank, 0); } diff --git a/42sh/src/line-editing/sigint_handler.c b/42sh/src/line-editing/sigint_handler.c index 0c2dad9c..f15da9d3 100644 --- a/42sh/src/line-editing/sigint_handler.c +++ b/42sh/src/line-editing/sigint_handler.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 15:14:47 by jhalford #+# #+# */ -/* Updated: 2017/01/09 15:59:05 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:16:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/shell_exit.c b/42sh/src/main/shell_exit.c index 882a3f31..02e32f49 100644 --- a/42sh/src/main/shell_exit.c +++ b/42sh/src/main/shell_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:37:04 by jhalford #+# #+# */ -/* Updated: 2017/01/08 15:55:39 by jhalford ### ########.fr */ +/* Updated: 2017/01/09 16:25:04 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,6 @@ void shell_exit(void) /* DG("cleanup. char * UP at %p", UP); */ /* DG("cleanup. char * BC at %p", BC); */ data_exit(); - /* job_kill_all(); */ + job_kill_all(); tcsetattr(0, TCSANOW, &data_singleton()->jobc.shell_tmodes); }