removed debug macros in job_control
This commit is contained in:
parent
95e1f03401
commit
e2e18d83bc
9 changed files with 9 additions and 32 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/11 18:01:10 by jhalford ### ########.fr */
|
/* Updated: 2017/01/31 13:47:57 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -30,7 +30,6 @@ int launch_process(t_process *p)
|
||||||
{
|
{
|
||||||
p->attributes &= ~PROCESS_STATE_MASK;
|
p->attributes &= ~PROCESS_STATE_MASK;
|
||||||
p->attributes |= PROCESS_RUNNING;
|
p->attributes |= PROCESS_RUNNING;
|
||||||
DG("process is to be forked, %i->[]->%i, attr=%b", p->fdin, p->fdout, p->attributes);
|
|
||||||
if (p->attributes & (PROCESS_BINARY | PROCESS_SCRIPT)
|
if (p->attributes & (PROCESS_BINARY | PROCESS_SCRIPT)
|
||||||
&& access(p->path, X_OK) == -1)
|
&& access(p->path, X_OK) == -1)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/05 16:09:40 by wescande #+# #+# */
|
/* Created: 2017/01/05 16:09:40 by wescande #+# #+# */
|
||||||
/* Updated: 2017/01/27 21:57:24 by wescande ### ########.fr */
|
/* Updated: 2017/01/31 13:43:56 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 15:10:20 by jhalford #+# #+# */
|
/* Created: 2016/12/13 15:10:20 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/12 15:15:21 by jhalford ### ########.fr */
|
/* Updated: 2017/01/31 13:50:40 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -25,12 +25,8 @@ int job_is_completed(int id)
|
||||||
while (lst)
|
while (lst)
|
||||||
{
|
{
|
||||||
p = lst->content;
|
p = lst->content;
|
||||||
DG("checking pid=%i", p->pid);
|
|
||||||
if (!(p->attributes & PROCESS_COMPLETED))
|
if (!(p->attributes & PROCESS_COMPLETED))
|
||||||
{
|
|
||||||
DG("process %i is not completed", p->pid);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
lst = lst->next;
|
lst = lst->next;
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */
|
/* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/12 15:16:05 by jhalford ### ########.fr */
|
/* Updated: 2017/01/31 13:44:26 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -19,11 +19,8 @@ void job_remove(int id)
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
if (job_is_completed(id))
|
if (job_is_completed(id))
|
||||||
{
|
{
|
||||||
DG("job_remove");
|
|
||||||
if (id < data_singleton()->jobc.current_id)
|
if (id < data_singleton()->jobc.current_id)
|
||||||
data_singleton()->jobc.current_id = id;
|
data_singleton()->jobc.current_id = id;
|
||||||
ft_lst_delif(&jobc->first_job, &id, job_cmp_id, job_free);
|
ft_lst_delif(&jobc->first_job, &id, job_cmp_id, job_free);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
DG("job_remove failed (not completed)");
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
|
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/12 15:14:38 by jhalford ### ########.fr */
|
/* Updated: 2017/01/31 13:44:17 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,19 +17,14 @@ int job_wait(int id)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
DG("job wait");
|
|
||||||
if (job_is_stopped(id) || job_is_completed(id))
|
if (job_is_stopped(id) || job_is_completed(id))
|
||||||
return (0);
|
return (0);
|
||||||
DG("waitpid now");
|
|
||||||
pid = waitpid(WAIT_ANY, &status, WUNTRACED);
|
pid = waitpid(WAIT_ANY, &status, WUNTRACED);
|
||||||
DG("waitpid done");
|
|
||||||
while (!process_mark_status(pid, status)
|
while (!process_mark_status(pid, status)
|
||||||
&& !job_is_completed(id)
|
&& !job_is_completed(id)
|
||||||
&& !job_is_stopped(id))
|
&& !job_is_stopped(id))
|
||||||
{
|
{
|
||||||
DG("waitpid now");
|
|
||||||
pid = waitpid(WAIT_ANY, &status, WUNTRACED);
|
pid = waitpid(WAIT_ANY, &status, WUNTRACED);
|
||||||
DG("waitpid done");
|
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/12 15:14:28 by jhalford ### ########.fr */
|
/* Updated: 2017/01/31 13:44:49 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
|
/* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/12 13:16:48 by jhalford ### ########.fr */
|
/* Updated: 2017/01/31 13:47:41 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,10 +17,8 @@ int put_job_in_foreground(t_job *job, int cont)
|
||||||
t_jobc *jobc;
|
t_jobc *jobc;
|
||||||
|
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
/* Send the job a continue signal, if necessary. */
|
|
||||||
if (cont)
|
if (cont)
|
||||||
{
|
{
|
||||||
/* Put the job into the foreground. */
|
|
||||||
signal(SIGTTOU, SIG_IGN);
|
signal(SIGTTOU, SIG_IGN);
|
||||||
if (tcsetpgrp(STDIN, job->pgid) == -1)
|
if (tcsetpgrp(STDIN, job->pgid) == -1)
|
||||||
DG("couldn't put process in control. errno=%i, pgid=%i", errno, job->pgid);
|
DG("couldn't put process in control. errno=%i, pgid=%i", errno, job->pgid);
|
||||||
|
|
@ -29,17 +27,11 @@ int put_job_in_foreground(t_job *job, int cont)
|
||||||
if (kill(-job->pgid, SIGCONT) < 0)
|
if (kill(-job->pgid, SIGCONT) < 0)
|
||||||
perror("kill (SIGCONT)");
|
perror("kill (SIGCONT)");
|
||||||
}
|
}
|
||||||
/* Wait for it to report. */
|
|
||||||
DG("gonna wait for job id=%i", job->id);
|
|
||||||
job_wait(job->id);
|
job_wait(job->id);
|
||||||
job_remove(job->id);
|
job_remove(job->id);
|
||||||
|
|
||||||
/* Put the shell back in the foreground. */
|
|
||||||
signal(SIGTTOU, SIG_IGN);
|
signal(SIGTTOU, SIG_IGN);
|
||||||
tcsetpgrp(STDIN, jobc->shell_pgid);
|
tcsetpgrp(STDIN, jobc->shell_pgid);
|
||||||
signal(SIGTTOU, sigttou_handler);
|
signal(SIGTTOU, sigttou_handler);
|
||||||
|
|
||||||
/* Restore the shell’s terminal modes. */
|
|
||||||
tcgetattr(STDIN, &job->tmodes);
|
tcgetattr(STDIN, &job->tmodes);
|
||||||
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
|
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
|
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/27 15:43:46 by wescande ### ########.fr */
|
/* Updated: 2017/01/31 13:42:01 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 13:09:12 by wescande ### ########.fr */
|
/* Updated: 2017/01/31 13:50:28 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -34,8 +34,6 @@ int shell_single_command(char *command)
|
||||||
if (ft_parse(&ast, &token))
|
if (ft_parse(&ast, &token))
|
||||||
return (1);
|
return (1);
|
||||||
btree_print(STDBUG, ast, &ft_putast);
|
btree_print(STDBUG, ast, &ft_putast);
|
||||||
/* /1* ft_dprintf(STDBUG, "\n--- INFIX BREAKDOWN ---\n"); *1/ */
|
|
||||||
/* /1* btree_apply_infix(ast, &ft_putast2); *1/ */
|
|
||||||
if (ft_exec(&ast))
|
if (ft_exec(&ast))
|
||||||
return (1);
|
return (1);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue