pipelines work. next step: handle trmcaps heavy programs like vim (used to work tho in foreground mode before)
This commit is contained in:
parent
ca89fcf53d
commit
9367075a9f
7 changed files with 15 additions and 14 deletions
|
|
@ -29,7 +29,8 @@ int exec_pipe(t_btree **ast)
|
|||
p->attributes &= ~PROCESS_PIPEEND;
|
||||
ft_exec(&(*ast)->left);
|
||||
p->attributes &= ~PROCESS_PIPESTART;
|
||||
if (p->fdout != STDOUT)
|
||||
|
||||
DG("p->fdout=%i", p->fdout);
|
||||
close(p->fdout);
|
||||
p->fdout = STDOUT;
|
||||
p->fdin = fds[PIPE_READ];
|
||||
|
|
@ -38,10 +39,9 @@ int exec_pipe(t_btree **ast)
|
|||
ft_exec(&(*ast)->right);
|
||||
if (start)
|
||||
p->attributes |= PROCESS_PIPESTART;
|
||||
/* close(fds[PIPE_WRITE]); */
|
||||
/* close(fds[PIPE_READ]); */
|
||||
|
||||
close(p->fdin);
|
||||
p->fdin = STDIN;
|
||||
p->fdout = STDOUT;
|
||||
btree_delone(ast, &ast_free);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ void process_reset(void)
|
|||
data = data_singleton();
|
||||
data->exec.process.path = NULL;
|
||||
data->exec.process.av = NULL;
|
||||
data->exec.process.fdin = STDIN;
|
||||
data->exec.process.fdout = STDOUT;
|
||||
/* data->exec.process.fdin = STDIN; */
|
||||
/* data->exec.process.fdout = STDOUT; */
|
||||
data->exec.process.pid = 0;
|
||||
data->exec.process.attributes = PROCESS_PIPESTART | PROCESS_PIPEEND;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ int builtin_jobs(const char *path, char *const av[], char *const envp[])
|
|||
firstp = 1;
|
||||
job = jlist->content;
|
||||
ft_printf("{mag}[%i] %c ", job->id, rank);
|
||||
if (lg)
|
||||
ft_printf("%i ", p->pid);
|
||||
ft_printf("attr=%#b ", job->attributes);
|
||||
plist = job->first_process;
|
||||
while (plist)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ int job_addprocess(t_process *p)
|
|||
job = jobc->first_job->content;
|
||||
if (p->pid > 0)
|
||||
{
|
||||
ft_lstadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
|
||||
ft_lsteadd(&job->first_process, ft_lstnew(p, sizeof(*p)));
|
||||
DG("added process to first_job : %i", p->pid);
|
||||
}
|
||||
if (JOB_IS_BG(job->attributes) && IS_PIPEEND(p->attributes))
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ int job_wait(int id)
|
|||
pid_t pid;
|
||||
int status;
|
||||
|
||||
if (job_is_stopped(id) || job_is_completed(id))
|
||||
return (0);
|
||||
pid = waitpid(WAIT_ANY, &status, WUNTRACED);
|
||||
while (!process_mark_status(pid, status)
|
||||
&& !job_is_stopped(id)
|
||||
|
|
@ -26,7 +28,7 @@ int job_wait(int id)
|
|||
pid = waitpid(WAIT_ANY, &status, WUNTRACED);
|
||||
DG("waitpid done");
|
||||
}
|
||||
/* DG("stopped: %i", job_is_stopped(job)); */
|
||||
/* DG("completed: %i", job_is_completed(job)); */
|
||||
DG("stopped: %i", job_is_stopped(id));
|
||||
DG("completed: %i", job_is_completed(id));
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ int put_job_in_foreground(t_job *job, int cont)
|
|||
perror("kill (SIGCONT)");
|
||||
}
|
||||
/* Wait for it to report. */
|
||||
DG("gonna wait for job");
|
||||
DG("gonna wait for job id=%i", job->id);
|
||||
/* if (!(p->attributes & PROCESS_BUILTIN && p->fdout == STDOUT)) */
|
||||
job_wait(job->id);
|
||||
job_remove(job->id);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ void sigchld_handler(int signo)
|
|||
DG("got asynchronous notification (SIGCHLD)");
|
||||
/* if (do_job_notification()) */
|
||||
/* ft_putstr(SHELL_PROMPT); */
|
||||
/* job_update_status(); */
|
||||
job_update_status();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue