job control NORM

This commit is contained in:
Jack Halford 2017-03-16 18:46:27 +01:00
parent f3673b1006
commit f65f23b10f
32 changed files with 87 additions and 159 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 16:01:30 by jhalford #+# #+# */
/* Updated: 2017/03/10 15:36:48 by jhalford ### ########.fr */
/* Updated: 2017/03/16 18:37:56 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,6 @@ int exec_ampersand(t_btree **ast)
return (exec_semi(ast));
exec = &data_singleton()->exec;
push(&exec->op_stack, TK_AMP);
exec->job.attrs |= JOB_BG;
ft_exec(&(*ast)->left);
exec->attrs &= ~EXEC_AOL_MASK;
exec->job.attrs &= ~JOB_BG;

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
/* Updated: 2017/03/15 19:58:48 by ariard ### ########.fr */
/* Updated: 2017/03/16 18:40:47 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -40,16 +40,14 @@ int exec_leaf(t_btree **ast)
p.map = g_process_map[p.type];
if (!(process_launch(&p)))
{
DG("forked pid=[%i]", p.pid);
job_addprocess(&p);
/* DG("[IS_BG->%i]", JOB_IS_BG(job->attrs)); */
if (IS_PIPEEND(p))
{
if (JOB_IS_FG(job->attrs))
put_job_in_foreground(job, 0);
DG("job->pgid RESET (end of pipe)");
job->pgid = 0;
}
DG("check");
}
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
/* Updated: 2017/03/11 14:19:41 by jhalford ### ########.fr */
/* Updated: 2017/03/16 16:55:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,7 +25,6 @@ int exec_reset(void)
ft_dprintf(2, "{red}%s: internal fcntl STDOUT error errno=%i{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{eoc}\n", SHELL_NAME, errno);
/* 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;
@ -33,6 +32,7 @@ int exec_reset(void)
exec->job.pgid = 0;
exec->job.attrs = 0;
exec->job.first_process = NULL;
tcgetattr(STDIN, &exec->job.tmodes);
jobc->first_job = NULL;
jobc->current_id = 1;
return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
/* Updated: 2017/03/15 02:04:38 by ariard ### ########.fr */
/* Updated: 2017/03/16 18:38:09 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/11 18:16:23 by jhalford ### ########.fr */
/* Updated: 2017/03/16 16:50:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,22 +17,10 @@ int mark_process_status(pid_t pid, int status)
t_list *plist;
t_process *p;
if (WIFEXITED(status))
DG("MPS pid=[%i] s=[%i] ec=[%i] (exited)", pid, status,
WEXITSTATUS(status));
else if (WIFSIGNALED(status))
DG("MPS pid=[%i] s=[%i] sig=[%i] (signaled)", pid, status,
WTERMSIG(status));
else if (WIFSTOPPED(status))
DG("MPS pid=[%i] s=[%i] (stopped)", pid, status);
else
DG("MPS pid=[%i] s=[%i] (unknown)", pid, status);
if ((plist = job_getprocess(pid)))
{
p = plist->content;
p->status = status;
/* DG("found pid=[%i], name=[%s]", p->pid, p->data.cmd.av[0]); */
if (WIFSTOPPED(status))
{
p->attrs &= ~PROCESS_STATE_MASK;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 19:09:30 by jhalford #+# #+# */
/* Updated: 2017/03/15 18:13:05 by ariard ### ########.fr */
/* Updated: 2017/03/16 18:42:45 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/15 00:55:31 by ariard ### ########.fr */
/* Updated: 2017/03/16 18:44:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,28 +6,12 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
/* Updated: 2017/03/15 23:52:30 by wescande ### ########.fr */
/* Updated: 2017/03/16 18:45:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
/* t_itof g_launchmap[] = */
/* { */
/* {PROCESS_FUNCTION, launch_function}, */
/* {PROCESS_BUILTIN, launch_builtin}, */
/* {PROCESS_FILE, launch_file}, */
/* {PROCESS_SUBSHELL, launch_subshell}, */
/* {PROCESS_BRACE, launch_brace}, */
/* {PROCESS_WHILE, launch_while}, */
/* {PROCESS_UNTIL, launch_until}, */
/* {PROCESS_IF, launch_if}, */
/* {PROCESS_FOR, launch_for}, */
/* {PROCESS_CASE, launch_case}, */
/* {PROCESS_EMPTY, launch_empty}, */
/* }; */
int check_pipe(t_process *p)
{
pid_t pid;
@ -61,24 +45,20 @@ int check_pipe(t_process *p)
int process_launch(t_process *p)
{
pid_t pid;
pid_t manage_pid;
/* pid_t manage_pid; */
DG("p->type=%i", p->type);
/* if (p->type >= PROCESS_MAX) */
/* return (-1); */
/* if (!g_launch_map[p->type].f) */
/* return (-1); */
p->attrs &= ~PROCESS_STATE_MASK;
p->attrs |= PROCESS_RUNNING;
if (!(manage_pid = check_pipe(p)))
/* if (!(manage_pid = check_pipe(p))) */
if (!(pid = (*p->map.launch)(p)))
{
DG("launcher did not fork!");
process_resetfds(p);
return (1);
}
if (manage_pid)
pid = manage_pid;
/* if (manage_pid) */
/* pid = manage_pid; */
DG("launcher forked!");
p->pid = pid;
process_setgroup(p, pid);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/15 18:20:38 by ariard ### ########.fr */
/* Updated: 2017/03/16 18:40:59 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -34,7 +34,6 @@ static int process_set_spec(t_process *p, t_btree *ast)
if (!ast)
return (0);
item = ast->item;
DG("process set spec");
while (g_setprocessmap[++i].id)
if (item->type == g_setprocessmap[i].id)
{
@ -62,6 +61,8 @@ int process_set(t_process *p, t_btree *ast)
fds[PIPE_READ] = STDIN;
if (op == TK_PIPE)
pipe(fds);
else if (op == TK_AMP)
exec->job.attrs |= JOB_BG;
p->fdin = exec->fdin;
p->to_close = fds[PIPE_READ];
p->fdout = fds[PIPE_WRITE];

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 16:54:18 by jhalford #+# #+# */
/* Updated: 2017/01/20 00:09:28 by ariard ### ########.fr */
/* Updated: 2017/03/16 16:49:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
/* Updated: 2017/03/15 11:24:23 by gwojda ### ########.fr */
/* Updated: 2017/03/16 18:35:01 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,21 +26,16 @@ int do_job_notification(void)
while (jlist)
{
j = jlist->content;
jlist = jlist->next;
if (job_is_completed(j->id)
|| (job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED)))
|| (job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED)))
{
ret = 1;
job_notify_change(j->id);
j->attrs |= JOB_NOTIFIED;
if (job_is_completed(j->id))
{
jlist = jlist->next;
job_remove(j->id);
continue ;
}
else
j->attrs |= JOB_NOTIFIED;
}
jlist = jlist->next;
}
return (ret);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
/* Updated: 2017/03/11 18:22:29 by jhalford ### ########.fr */
/* Updated: 2017/03/16 18:24:01 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,14 +23,12 @@ int job_addprocess(t_process *p)
{
job_update_id();
job->id = jobc->current_id;
job->pgid = SH_IS_INTERACTIVE(data_singleton()->opts) ? p->pid : getpgid(0);
/* job->pgid = p->pid; */
job->pgid = SH_IS_INTERACTIVE(data_singleton()->opts) ?
p->pid : getpgid(0);
ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job)));
}
DG("adding pid=[%i] to pgid=[%i]", p->pid, job->pgid);
job = jobc->first_job->content;
ft_lsteadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
/* DG("[BG:%i]", JOB_IS_BG(job->attrs)); */
if (JOB_IS_BG(job->attrs) && IS_PIPEEND(*p))
job_notify_new(job);
return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 15:10:20 by jhalford #+# #+# */
/* Updated: 2017/03/06 12:30:22 by wescande ### ########.fr */
/* Updated: 2017/03/16 18:26:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 15:06:45 by jhalford #+# #+# */
/* Updated: 2017/03/08 20:53:25 by jhalford ### ########.fr */
/* Updated: 2017/03/16 18:26:27 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */
/* Updated: 2017/03/10 14:40:16 by jhalford ### ########.fr */
/* Updated: 2017/03/16 18:29:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,15 +15,17 @@
void job_remove(int id)
{
t_jobc *jobc;
t_job *j;
t_job *j;
t_list *jlist;
t_process *p;
jobc = &data_singleton()->jobc;
j = ft_lst_find(jobc->first_job, &id, job_cmp_id)->content;
if (!(jlist = ft_lst_find(jobc->first_job, &id, job_cmp_id)))
return ;
j = jlist->content;
if (job_is_completed(id))
{
p = ft_lstlast(j->first_process)->content;
/* DG("remove, status=%i", p->status); */
set_exitstatus(p->status, 0);
if (id < data_singleton()->jobc.current_id)
data_singleton()->jobc.current_id = id;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
/* Updated: 2017/03/14 23:43:00 by jhalford ### ########.fr */
/* Updated: 2017/03/16 18:32:15 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,12 +17,13 @@ void job_update_status(void)
int status;
pid_t pid;
do
while (1)
{
if ((pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG)) == -1
&& errno != ECHILD)
ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n", SHELL_NAME, errno);
DG("pid=[%d]", pid);
ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n",
SHELL_NAME, errno);
if (pid <= 1 || mark_process_status(pid, status))
break ;
}
while (pid > 1 && !mark_process_status(pid, status));
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
/* Updated: 2017/03/15 18:12:30 by jhalford ### ########.fr */
/* Updated: 2017/03/16 18:01:57 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,16 +21,16 @@ int job_wait(int 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
while (1)
{
if ((pid = waitpid(-j->pgid, &status, WUNTRACED)) == -1
&& errno != ECHILD)
ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n", SHELL_NAME, errno);
DG("waitpid->[%d]", pid);
ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n",
SHELL_NAME, errno);
if (pid <= 1 || mark_process_status(pid, status)
|| job_is_stopped(id)
|| job_is_completed(id))
break ;
}
while (pid > 1 && !mark_process_status(pid, status)
&& !job_is_stopped(id)
&& !job_is_completed(id));
return (0);
}

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_case.c :+: :+: :+: */
/* pprint_case.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:15:22 by wescande #+# #+# */
/* Updated: 2017/03/13 20:41:59 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:58:56 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:58:56 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_cmd.c :+: :+: :+: */
/* pprint_cmd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:17:16 by wescande #+# #+# */
/* Updated: 2017/03/13 20:23:18 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:55:30 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:55:34 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_for.c :+: :+: :+: */
/* pprint_for.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:14:21 by wescande #+# #+# */
/* Updated: 2017/03/13 20:23:18 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:55:26 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:55:27 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_function.c :+: :+: :+: */
/* pprint_function.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:12:18 by wescande #+# #+# */
/* Updated: 2017/03/13 20:23:18 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:53:36 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:53:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_if.c :+: :+: :+: */
/* pprint_if.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:14:48 by wescande #+# #+# */
/* Updated: 2017/03/13 20:23:18 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:53:20 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:53:21 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_subshell.c :+: :+: :+: */
/* pprint_subshell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:06:06 by wescande #+# #+# */
/* Updated: 2017/03/13 20:23:18 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:53:59 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:54:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_until.c :+: :+: :+: */
/* pprint_until.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:16:00 by wescande #+# #+# */
/* Updated: 2017/03/13 20:23:18 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:53:43 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:53:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pprint_while.c :+: :+: :+: */
/* pprint_while.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:15:01 by wescande #+# #+# */
/* Updated: 2017/03/13 20:23:18 by jhalford ### ########.fr */
/* Created: 2017/03/16 16:53:29 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:53:30 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:39:58 by jhalford ### ########.fr */
/* Updated: 2017/03/16 16:41:10 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,36 +6,18 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
/* Updated: 2017/03/14 20:19:22 by wescande ### ########.fr */
/* Updated: 2017/03/16 16:53:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
/* t_itof g_freemap[] = */
/* { */
/* {PROCESS_FUNCTION, process_free_subshell}, */
/* {PROCESS_BUILTIN, process_free_cmd}, */
/* {PROCESS_FILE, process_free_cmd}, */
/* {PROCESS_SUBSHELL, process_free_subshell}, */
/* {PROCESS_WHILE, process_free_cond}, */
/* {PROCESS_UNTIL, process_free_cond}, */
/* {PROCESS_IF, process_free_cond}, */
/* {PROCESS_FOR, process_free_list}, */
/* {PROCESS_CASE, process_free_list}, */
/* {PROCESS_EMPTY, NULL}, */
/* }; */
void process_free(void *content, size_t content_size)
{
t_process *p;
p = content;
(void)content_size;
/* if (p->type >= PROCESS_MAX) */
/* return ; */
/* if (g_freemap[p->type].f) */
/* (g_freemap[p->type].f)(p); */
if (p->map.free)
(p->map.free)(p);
ft_lstdel(&p->redirs, redir_free);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
/* Updated: 2017/03/15 15:51:30 by gwojda ### ########.fr */
/* Updated: 2017/03/16 16:51:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,19 +17,15 @@ int put_job_in_foreground(t_job *j, int cont)
t_jobc *jobc;
jobc = &data_singleton()->jobc;
DG("tcsetpgrp[%i]", j->pgid);
if (SH_IS_INTERACTIVE(data_singleton()->opts))
tcsetpgrp(STDIN, j->pgid);
if (cont)
{
// j->tmodes = pas initialisé !
//tcsetattr(STDIN, TCSADRAIN, &j->tmodes);
tcsetattr(STDIN, TCSADRAIN, &j->tmodes);
if (kill(-j->pgid, SIGCONT) < 0)
DG("kill(SIGCONT) failed");
}
DG("check");
job_wait(j->id);
DG("check");
if (SH_IS_INTERACTIVE(data_singleton()->opts))
{
tcsetpgrp(STDIN, jobc->shell_pgid);
@ -37,6 +33,5 @@ int put_job_in_foreground(t_job *j, int cont)
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
}
job_remove(j->id);
DG("check");
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */
/* Updated: 2017/03/05 15:30:58 by wescande ### ########.fr */
/* Updated: 2017/03/16 16:52:46 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,10 +14,5 @@
void sigtstp_handler(int signo)
{
// t_jobc *jobc;
(void)signo;
// jobc = &data_singleton()->jobc;
DG("got SIGTSTP pid=%i, pgrp=%i, shell_pgid=%i", getpid(), getpgrp(), data_singleton()->jobc.shell_pgid);
ft_putchar('\x1A');
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2017/03/15 16:23:18 by wescande ### ########.fr */
/* Updated: 2017/03/16 16:47:55 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/16 16:36:34 by jhalford ### ########.fr */
/* Updated: 2017/03/16 18:01:32 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/15 13:55:49 by gwojda ### ########.fr */
/* Updated: 2017/03/16 16:47:50 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,7 +25,6 @@ static int interactive_settings(void)
t_data *data;
data = data_singleton();
DG("interactive shell settings");
shell_pgid = &data->jobc.shell_pgid;
while (tcgetpgrp(STDIN) != (*shell_pgid = getpgrp()))
kill(-*shell_pgid, SIGTTIN);
@ -54,17 +53,12 @@ int shell_init(int ac, char **av)
data_init(ac, av);
if (isatty(STDIN) && !*cliopts_getdata(av))
{
DG("interactive");
data->opts |= SH_INTERACTIVE;
data->opts |= SH_OPTS_JOBC;
}
else
DG("non interactive");
if (cliopts_get(av, g_opts, data))
return (ft_perror());
if (SH_IS_INTERACTIVE(data->opts))
interactive_settings();
else
DG("not interactive");
return (0);
}