pgid stuff, still must fix (ls)

This commit is contained in:
Jack Halford 2017-03-10 17:08:04 +01:00
parent b7a1f9e92f
commit 0a205229a8
13 changed files with 20 additions and 25 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
}
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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));

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */