end of holidays commit
This commit is contained in:
parent
c9a39637da
commit
14e5d176aa
10 changed files with 13 additions and 50 deletions
|
|
@ -38,7 +38,6 @@ struct s_jobc
|
|||
t_list *first_job;
|
||||
pid_t shell_pgid;
|
||||
int current_id;
|
||||
int rank[2];
|
||||
struct termios shell_tmodes;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ int exec_command(t_btree **ast)
|
|||
DG("gonna launch_process now");
|
||||
launch_process(p);
|
||||
job_addprocess(p);
|
||||
if (IS_PIPEEND(p->fdout == STDOUT))
|
||||
if (IS_PIPEEND(p->attributes))
|
||||
{
|
||||
if (JOB_IS_FG(job->attributes))
|
||||
put_job_in_foreground(job, 0);
|
||||
|
|
|
|||
|
|
@ -24,18 +24,17 @@ int exec_pipe(t_btree **ast)
|
|||
DG("pipe %i->%i", fds[PIPE_WRITE], fds[PIPE_READ]);
|
||||
p->fdout = fds[PIPE_WRITE];
|
||||
if (!IS_PIPEEND(p->attributes))
|
||||
{
|
||||
p->attributes |= PROCESS_PIPESTART;
|
||||
else
|
||||
p->attributes &= ~PROCESS_PIPESTART;
|
||||
p->attributes &= ~PROCESS_PIPEEND;
|
||||
}
|
||||
|
||||
ft_exec(&(*ast)->left);
|
||||
if (p->fdout != STDOUT)
|
||||
close(p->fdout);
|
||||
p->fdout = STDOUT;
|
||||
p->fdin = fds[PIPE_READ];
|
||||
|
||||
p->attributes ~= ~PROCESS_PIPESTART;
|
||||
p->attributes &= ~PROCESS_PIPESTART;
|
||||
p->attributes |= PROCESS_PIPEEND;
|
||||
|
||||
ft_exec(&(*ast)->right);
|
||||
|
|
@ -43,6 +42,7 @@ int exec_pipe(t_btree **ast)
|
|||
/* close(fds[PIPE_READ]); */
|
||||
p->fdin = STDIN;
|
||||
p->fdout = STDOUT;
|
||||
p->attributes |= PROCESS_PIPESTART;
|
||||
p->attributes &= ~PROCESS_PIPEEND;
|
||||
btree_delone(ast, &ast_free);
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ int launch_process(t_process *p)
|
|||
}
|
||||
else
|
||||
{
|
||||
DG("process is to be forked, fdout=%i, attr=%x", p->fdout, p->attributes);
|
||||
DG("process is to be forked, fdout=%i, attr=%b", p->fdout, p->attributes);
|
||||
if (p->attributes & (PROCESS_BINARY | PROCESS_SCRIPT)
|
||||
&& access(p->path, X_OK) == -1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ int job_addprocess(t_process *p)
|
|||
job_update_id();
|
||||
job->id = jobc->current_id;
|
||||
ft_lstadd(&jobc->first_job, ft_lstnew(job, sizeof(*job)));
|
||||
DG("added new job [%i], rank=%i:%i", job->id, jobc->rank[0], jobc->rank[1]);
|
||||
DG("added new job [%i]", job->id);
|
||||
}
|
||||
job = jobc->first_job->content;
|
||||
ft_lstadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* job_shiftstatus.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 13:05:10 by jhalford #+# #+# */
|
||||
/* Updated: 2016/12/12 17:23:12 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "job_control.h"
|
||||
|
||||
void job_update_rank()
|
||||
{
|
||||
t_jobc *jobc;
|
||||
t_job *job;
|
||||
t_list *list;
|
||||
|
||||
jobc = &data_singleton()->jobc;
|
||||
list = jobc->first_job;
|
||||
if (list)
|
||||
{
|
||||
job = list->content;
|
||||
jobc->rank[0] = job->id;
|
||||
jobc->rank[1] = list->next ? ((t_job*)list->next->content)->id : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
jobc->rank[0] = 0;
|
||||
jobc->rank[1] = 0;
|
||||
}
|
||||
DG("updated rank: %i,%i", jobc->rank[0], jobc->rank[1]);
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ int process_mark_status(pid_t pid, int status)
|
|||
t_process *p;
|
||||
|
||||
DG("marking: pid=%i, status=%i", pid, status);
|
||||
if (pid > 0)
|
||||
if (pid > 1)
|
||||
{
|
||||
if ((p = job_getprocess(pid)))
|
||||
{
|
||||
|
|
@ -37,8 +37,5 @@ int process_mark_status(pid_t pid, int status)
|
|||
ft_dprintf(2, "No child process %d.\n", pid);
|
||||
return(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ int put_job_in_foreground(t_job *job, int cont)
|
|||
if (cont)
|
||||
{
|
||||
tcsetattr (STDIN_FILENO, TCSADRAIN, &job->tmodes);
|
||||
if (kill(- job->pgid, SIGCONT) < 0)
|
||||
if (kill(-job->pgid, SIGCONT) < 0)
|
||||
perror("kill (SIGCONT)");
|
||||
}
|
||||
/* Wait for it to report. */
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ int ft_interactive_sh(t_data *data)
|
|||
|
||||
if ((input_init(data)))
|
||||
return (-1);
|
||||
DG("interactive_sh loop");
|
||||
while (1)
|
||||
{
|
||||
ft_bzero(buf, 4);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ int data_init(void)
|
|||
data->exec.process.fdin = STDIN;
|
||||
data->exec.process.fdout = STDOUT;
|
||||
data->exec.process.pid = 0;
|
||||
data->exec.process.attributes = PROCESS_PIPESTART;
|
||||
data->exec.aol_status = NULL;
|
||||
data->exec.aol_search = 0;
|
||||
data->exec.job.id = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue