diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 5013d09c..d67c687b 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/10 15:38:44 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:57:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_leaf.c b/42sh/src/exec/exec_leaf.c index 424cf51f..f750c5e7 100644 --- a/42sh/src/exec/exec_leaf.c +++ b/42sh/src/exec/exec_leaf.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ -/* Updated: 2017/03/10 15:36:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:58:57 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,8 +29,6 @@ int exec_leaf(t_btree **ast) { if (JOB_IS_FG(job->attrs)) put_job_in_foreground(job, 0); - /* else */ - /* put_job_in_background(job, 0); */ job->pgid = 0; } } diff --git a/42sh/src/exec/exec_reset.c b/42sh/src/exec/exec_reset.c index 354b3cde..df434fd0 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/10 13:48:19 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:49:14 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,15 +20,13 @@ int exec_reset(void) /* exec->fd_save[0] = 1;//fcntl(STDIN, F_DUPFD_CLOEXEC); */ /* exec->fd_save[1] = 1;//fcntl(STDOUT, F_DUPFD_CLOEXEC); */ /* exec->fd_save[2] = 1;//fcntl(STDERR, F_DUPFD_CLOEXEC); */ - DG("check 0"); if ((exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF) ft_dprintf(2, "{red}%s: internal fcntl STDIN error errno=%i %s{eoc}\n", SHELL_NAME, errno); - DG("check 1"); if ((exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF) ft_dprintf(2, "{red}%s: internal fcntl STDOUT error errno=%i %s{eoc}\n", SHELL_NAME, errno); if ((exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF) ft_dprintf(2, "{red}%s: internal fcntl STDERR error errno=%i %s{eoc}\n", SHELL_NAME, errno); - DG("saved [%i:%i:%i]", exec->fd_save[0], exec->fd_save[1], exec->fd_save[2]); + /* DG("saved [%i:%i:%i]", exec->fd_save[0], exec->fd_save[1], exec->fd_save[2]); */ exec->op_stack = NULL; exec->fdin = STDIN; exec->attrs = 0; diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index ce257525..0fff5117 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/03/10 15:21:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:50:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/launch_while.c b/42sh/src/exec/launch_while.c index 462edb8b..b2268d0d 100644 --- a/42sh/src/exec/launch_while.c +++ b/42sh/src/exec/launch_while.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 17:20:53 by wescande #+# #+# */ -/* Updated: 2017/03/08 15:18:36 by wescande ### ########.fr */ +/* Updated: 2017/03/10 17:01:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/mark_process_status.c b/42sh/src/exec/mark_process_status.c index 57b21b34..f07a5784 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/10 12:51:05 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:28:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/process_setgroup.c b/42sh/src/exec/process_setgroup.c index 37cf1b81..cc63b209 100644 --- a/42sh/src/exec/process_setgroup.c +++ b/42sh/src/exec/process_setgroup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */ -/* Updated: 2017/03/09 14:28:39 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:51:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,8 +23,7 @@ int process_setgroup(t_process *p, pid_t pid) if (!SH_HAS_JOBC(data->opts)) return (0); j = &data->exec.job; - if (!j->pgid) - j->pgid = pid ? pid : getpid(); + /* DG("setpgid(%i, %i)", pid, j->pgid); */ setpgid(pid, j->pgid); if (pid == 0 && JOB_IS_FG(j->attrs)) tcsetpgrp(STDIN, j->pgid); diff --git a/42sh/src/job-control/builtin_fg.c b/42sh/src/job-control/builtin_fg.c index 9e7720f6..df1cf8c1 100644 --- a/42sh/src/job-control/builtin_fg.c +++ b/42sh/src/job-control/builtin_fg.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/08 14:30:07 by jhalford #+# #+# */ -/* Updated: 2017/02/21 20:09:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:27:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/job_addprocess.c b/42sh/src/job-control/job_addprocess.c index fb153c30..e8dd64ea 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/10 15:36:33 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:45:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,15 +27,12 @@ int job_addprocess(t_process *p) job->pgid = p->pid; ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job))); } - DG("check 0"); job = jobc->first_job->content; ft_lsteadd(&job->first_process, ft_lstnew(p, sizeof(*p))); - DG("[BG:%i]", JOB_IS_BG(job->attrs)); + /* DG("[BG:%i]", JOB_IS_BG(job->attrs)); */ if (JOB_IS_BG(job->attrs) && IS_PIPEEND(*p)) { - DG("check 2"); job_notify_new(job); } - DG("check 3"); return (0); } diff --git a/42sh/src/job-control/job_update_status.c b/42sh/src/job-control/job_update_status.c index a3088f15..33c3eb72 100644 --- a/42sh/src/job-control/job_update_status.c +++ b/42sh/src/job-control/job_update_status.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */ -/* Updated: 2017/03/10 15:38:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:45:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/job_wait.c b/42sh/src/job-control/job_wait.c index d655567f..8aa3be7f 100644 --- a/42sh/src/job-control/job_wait.c +++ b/42sh/src/job-control/job_wait.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */ -/* Updated: 2017/03/10 15:40:32 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:48:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,11 +19,14 @@ int job_wait(int id) t_jobc *jobc; int status; - DG("job wait [%i]", id); jobc = &data_singleton()->jobc; j = ft_lst_find(jobc->first_job, &id, job_cmp_id)->content; + DG("job wait id=[%i], pgid=[%i]", id, j->pgid); do + { pid = waitpid(-j->pgid, &status, WUNTRACED); + DG("pid=[%d]", pid); + } while (pid > 1 && !mark_process_status(pid, status) && !job_is_stopped(id) && !job_is_completed(id)); diff --git a/42sh/src/job-control/process_format.c b/42sh/src/job-control/process_format.c index c8a36422..9fcd987f 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/08 20:08:26 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:27:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/put_job_in_foreground.c b/42sh/src/job-control/put_job_in_foreground.c index 97b9ba4a..b07f40be 100644 --- a/42sh/src/job-control/put_job_in_foreground.c +++ b/42sh/src/job-control/put_job_in_foreground.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ -/* Updated: 2017/03/10 15:16:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/10 16:27:05 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */