hanged jobs printing and some other stuff
This commit is contained in:
parent
0c938e8963
commit
c2952d577c
32 changed files with 90 additions and 97 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:46:53 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 19:15:13 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -218,17 +218,4 @@ int exec_var(t_btree **ast);
|
||||||
int exec_case_branch(t_btree **ast);
|
int exec_case_branch(t_btree **ast);
|
||||||
int exec_math(t_btree **ast);
|
int exec_math(t_btree **ast);
|
||||||
|
|
||||||
/*
|
|
||||||
** Mapping pour afficher les process
|
|
||||||
*/
|
|
||||||
void process_print(t_process *p);
|
|
||||||
int process_print_subshell(void);
|
|
||||||
int process_print_while(void);
|
|
||||||
int process_print_if(void);
|
|
||||||
int process_print_case(void);
|
|
||||||
int process_print_until(void);
|
|
||||||
int process_print_function(void);
|
|
||||||
int process_print_for(void);
|
|
||||||
void process_print_cmd(t_process *p);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
|
/* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:45:21 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:06:47 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -84,5 +84,17 @@ void sigttou_handler(int signo);
|
||||||
|
|
||||||
int process_cmp_pid(t_process *p, pid_t *pid);
|
int process_cmp_pid(t_process *p, pid_t *pid);
|
||||||
void process_format(t_list **p, int firstp, int opts);
|
void process_format(t_list **p, int firstp, int opts);
|
||||||
|
/*
|
||||||
|
** Mapping pour afficher les process
|
||||||
|
*/
|
||||||
|
void process_print(t_process *p);
|
||||||
|
int process_print_subshell(t_process *p);
|
||||||
|
int process_print_while(t_process *p);
|
||||||
|
int process_print_if(t_process *p);
|
||||||
|
int process_print_case(t_process *p);
|
||||||
|
int process_print_until(t_process *p);
|
||||||
|
int process_print_function(t_process *p);
|
||||||
|
int process_print_for(t_process *p);
|
||||||
|
int process_print_cmd(t_process *p);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:40:14 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:31:12 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -22,6 +22,7 @@ int exec_leaf(t_btree **ast)
|
||||||
return (1);
|
return (1);
|
||||||
if (!(launch_process(&p)))
|
if (!(launch_process(&p)))
|
||||||
{
|
{
|
||||||
|
DG("forked pid=[%i], name=[%s]", p.pid, p.data.cmd.av[0]);
|
||||||
job_addprocess(&p);
|
job_addprocess(&p);
|
||||||
if (IS_PIPEEND(p))
|
if (IS_PIPEEND(p))
|
||||||
{
|
{
|
||||||
|
|
@ -29,9 +30,9 @@ int exec_leaf(t_btree **ast)
|
||||||
put_job_in_foreground(job, 0);
|
put_job_in_foreground(job, 0);
|
||||||
else
|
else
|
||||||
put_job_in_background(job, 0);
|
put_job_in_background(job, 0);
|
||||||
}
|
|
||||||
job->pgid = 0;
|
job->pgid = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (p.fdout != STDOUT)
|
if (p.fdout != STDOUT)
|
||||||
close(p.fdout);
|
close(p.fdout);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 14:45:54 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:46:03 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,13 +23,13 @@ t_itof g_launchmap[] =
|
||||||
{PROCESS_IF, launch_if},
|
{PROCESS_IF, launch_if},
|
||||||
{PROCESS_FOR, launch_for},
|
{PROCESS_FOR, launch_for},
|
||||||
{PROCESS_CASE, launch_case},
|
{PROCESS_CASE, launch_case},
|
||||||
{0, NULL}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int launch_process(t_process *p)
|
int launch_process(t_process *p)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
|
DG("launchprocess");
|
||||||
if (p->type >= PROCESS_MAX)
|
if (p->type >= PROCESS_MAX)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (!g_launchmap[p->type].f)
|
if (!g_launchmap[p->type].f)
|
||||||
|
|
|
||||||
|
|
@ -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/03/08 17:44:22 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 18:49:49 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,13 +17,14 @@ int mark_process_status(pid_t pid, int status)
|
||||||
t_list *plist;
|
t_list *plist;
|
||||||
t_process *p;
|
t_process *p;
|
||||||
|
|
||||||
|
DG("MPS pid=%i,s=%i", pid, status);
|
||||||
if (pid > 1)
|
if (pid > 1)
|
||||||
{
|
{
|
||||||
DG("MPS pid=%i,s=%i", pid, status);
|
|
||||||
if ((plist = job_getprocess(pid)))
|
if ((plist = job_getprocess(pid)))
|
||||||
{
|
{
|
||||||
p = plist->content;
|
p = plist->content;
|
||||||
p->status = status;
|
p->status = status;
|
||||||
|
DG("marking pid=[%i], name=[%s]", p->pid, p->data.cmd.av[0]);
|
||||||
if (WIFSTOPPED(status))
|
if (WIFSTOPPED(status))
|
||||||
{
|
{
|
||||||
p->attrs &= ~PROCESS_STATE_MASK;
|
p->attrs &= ~PROCESS_STATE_MASK;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/03 16:34:02 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:53:48 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 15:06:05 by wescande #+# #+# */
|
/* Created: 2017/03/07 15:06:05 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:13:30 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 18:49:55 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,7 +21,6 @@ int set_process_cmd(t_process *p, t_btree *ast)
|
||||||
p->data.cmd.path = NULL;
|
p->data.cmd.path = NULL;
|
||||||
p->data.cmd.execf = NULL;
|
p->data.cmd.execf = NULL;
|
||||||
p->data.cmd.stat = ft_memalloc(sizeof(struct stat));
|
p->data.cmd.stat = ft_memalloc(sizeof(struct stat));
|
||||||
/* DG("gonna setexec av[0]=[%s]", p->data.cmd.av[0]); */
|
|
||||||
p->type = PROCESS_FILE;
|
p->type = PROCESS_FILE;
|
||||||
if ((func = is_function(p)))
|
if ((func = is_function(p)))
|
||||||
{
|
{
|
||||||
|
|
@ -40,7 +39,6 @@ int set_process_cmd(t_process *p, t_btree *ast)
|
||||||
else if (ft_hash(p))
|
else if (ft_hash(p))
|
||||||
{
|
{
|
||||||
p->data.cmd.execf = &execve;
|
p->data.cmd.execf = &execve;
|
||||||
/* DG("found hash at [%s]", p->data.cmd.path); */
|
|
||||||
if (stat(p->data.cmd.path, p->data.cmd.stat) == -1)
|
if (stat(p->data.cmd.path, p->data.cmd.stat) == -1)
|
||||||
{
|
{
|
||||||
ft_memdel((void**)&p->data.cmd.stat);
|
ft_memdel((void**)&p->data.cmd.stat);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
|
/* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/31 15:05:34 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 18:52:24 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
|
/* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:52:29 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:35:18 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
|
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:40:08 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:16:09 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ int job_addprocess(t_process *p)
|
||||||
|
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
job = &data_singleton()->exec.job;
|
job = &data_singleton()->exec.job;
|
||||||
DG("adding pid=[%i] to job");
|
DG("adding pid=[%i] to job", p->pid);
|
||||||
if (IS_PIPESTART(*p))
|
if (IS_PIPESTART(*p))
|
||||||
{
|
{
|
||||||
job_update_id();
|
job_update_id();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 15:06:45 by jhalford #+# #+# */
|
/* Created: 2016/12/13 15:06:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/06 12:31:00 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 20:53:25 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:27:01 by jhalford #+# #+# */
|
/* Created: 2016/12/13 14:27:01 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:22:16 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 18:28:01 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/03/08 17:41:07 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 18:18:34 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
|
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:41:18 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:35:12 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,6 +18,9 @@ void job_update_status(void)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
do
|
do
|
||||||
pid = waitpid (WAIT_ANY, &status, WUNTRACED|WNOHANG);
|
{
|
||||||
while (!mark_process_status (pid, status));
|
pid = waitpid(WAIT_ANY, &status, WUNTRACED | WNOHANG);
|
||||||
|
DG("pid=[%d]", pid);
|
||||||
|
}
|
||||||
|
while (!mark_process_status(pid, status));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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/03/08 17:24:07 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:46:24 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,11 +15,15 @@
|
||||||
int job_wait(int id)
|
int job_wait(int id)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
t_job *j;
|
||||||
|
t_jobc *jobc;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
DG("job wait [%i]", id);
|
DG("job wait [%i]", id);
|
||||||
|
jobc = &data_singleton()->jobc;
|
||||||
|
j = ft_lst_find(jobc->first_job, &id, job_cmp_id)->content;
|
||||||
do
|
do
|
||||||
pid = waitpid(WAIT_ANY, &status, WUNTRACED);
|
pid = waitpid(-j->pgid, &status, WUNTRACED);
|
||||||
while (!mark_process_status(pid, status)
|
while (!mark_process_status(pid, status)
|
||||||
&& !job_is_stopped(id)
|
&& !job_is_stopped(id)
|
||||||
&& !job_is_completed(id));
|
&& !job_is_completed(id));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
|
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:21:18 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 20:08:26 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -42,15 +42,6 @@ static void process_format_com_long(t_list **plist)
|
||||||
t_process *p;
|
t_process *p;
|
||||||
|
|
||||||
p = (*plist)->content;
|
p = (*plist)->content;
|
||||||
/* if (p->attrs & PROCESS_CONTROL)
|
|
||||||
ft_putstr("script");
|
|
||||||
else if (p->attrs & PROCESS_SUBSHELL)
|
|
||||||
{
|
|
||||||
ft_putstr("( ");
|
|
||||||
// ft_putstr(p->data.cmd.av[2]);
|
|
||||||
ft_putstr(" )");
|
|
||||||
}
|
|
||||||
else*/
|
|
||||||
process_print(p);
|
process_print(p);
|
||||||
if ((*plist)->next)
|
if ((*plist)->next)
|
||||||
ft_putstr(" |");
|
ft_putstr(" |");
|
||||||
|
|
|
||||||
|
|
@ -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/03/08 12:40:22 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:13:57 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,7 +23,6 @@ t_itof g_freemap[] =
|
||||||
{PROCESS_IF, process_free_cond},
|
{PROCESS_IF, process_free_cond},
|
||||||
{PROCESS_FOR, process_free_list},
|
{PROCESS_FOR, process_free_list},
|
||||||
{PROCESS_CASE, process_free_list},
|
{PROCESS_CASE, process_free_list},
|
||||||
{0, NULL}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void process_free(void *content, size_t content_size)
|
void process_free(void *content, size_t content_size)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:03:32 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:03:32 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:20:19 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 20:44:26 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,26 +15,20 @@
|
||||||
t_itof g_printmap[] =
|
t_itof g_printmap[] =
|
||||||
{
|
{
|
||||||
{PROCESS_FUNCTION, process_print_function},
|
{PROCESS_FUNCTION, process_print_function},
|
||||||
{PROCESS_BUILTIN, NULL},
|
{PROCESS_BUILTIN, process_print_cmd},
|
||||||
{PROCESS_FILE, NULL},
|
{PROCESS_FILE, process_print_cmd},
|
||||||
{PROCESS_SUBSHELL, process_print_subshell},
|
{PROCESS_SUBSHELL, process_print_subshell},
|
||||||
{PROCESS_WHILE, process_print_while},
|
{PROCESS_WHILE, process_print_while},
|
||||||
{PROCESS_UNTIL, process_print_until},
|
{PROCESS_UNTIL, process_print_until},
|
||||||
{PROCESS_IF, process_print_if},
|
{PROCESS_IF, process_print_if},
|
||||||
{PROCESS_FOR, process_print_for},
|
{PROCESS_FOR, process_print_for},
|
||||||
{PROCESS_CASE, process_print_case},
|
{PROCESS_CASE, process_print_case},
|
||||||
{0, NULL}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void process_print(t_process *p)
|
void process_print(t_process *p)
|
||||||
{
|
{
|
||||||
if (p->type == PROCESS_BUILTIN || p->type == PROCESS_FUNCTION)
|
|
||||||
{
|
|
||||||
process_print_cmd(p);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
if (p->type >= PROCESS_MAX)
|
if (p->type >= PROCESS_MAX)
|
||||||
return ;
|
return ;
|
||||||
if (g_printmap[p->type].f)
|
if (g_printmap[p->type].f)
|
||||||
(g_printmap[p->type].f)();
|
(*g_printmap[p->type].f)(p);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:15:22 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:15:22 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:15:38 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 19:13:50 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int process_print_case(void)
|
int process_print_case(t_process *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
ft_putstr("CASE GROUP");
|
ft_putstr("CASE GROUP");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,14 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:17:16 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:17:16 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:20:11 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 20:28:10 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
void process_print_cmd(t_process *p)
|
int process_print_cmd(t_process *p)
|
||||||
{
|
{
|
||||||
ft_sstrprint(p->data.cmd.av, ' ');
|
ft_sstrprint(p->data.cmd.av, ' ');
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:14:21 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:14:21 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:14:32 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 19:13:16 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int process_print_for(void)
|
int process_print_for(t_process *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
ft_putstr("FOR GROUP");
|
ft_putstr("FOR GROUP");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:12:18 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:12:18 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:12:44 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 19:13:54 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int process_print_function(void)
|
int process_print_function(t_process *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
ft_putstr("FUNCTION GROUP");
|
ft_putstr("FUNCTION GROUP");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:14:48 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:14:48 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:14:55 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 19:14:01 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int process_print_if(void)
|
int process_print_if(t_process *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
ft_putstr("IF GROUP");
|
ft_putstr("IF GROUP");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:06:06 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:06:06 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:11:58 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 19:14:54 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int process_print_subshell(void)
|
int process_print_subshell(t_process *p)
|
||||||
{
|
{
|
||||||
ft_putstr("( SUBSHELL GROUP )");
|
(void)p;
|
||||||
|
ft_putstr("SUBSHELL GROUP");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:16:00 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:16:00 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:16:17 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 19:13:36 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int process_print_until(void)
|
int process_print_until(t_process *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
ft_putstr("UNTIL GROUP");
|
ft_putstr("UNTIL GROUP");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 16:15:01 by wescande #+# #+# */
|
/* Created: 2017/03/08 16:15:01 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/08 16:15:15 by wescande ### ########.fr */
|
/* Updated: 2017/03/08 19:14:13 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int process_print_while(void)
|
int process_print_while(t_process *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
ft_putstr("WHILE GROUP");
|
ft_putstr("WHILE GROUP");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 15:03:29 by jhalford #+# #+# */
|
/* Created: 2016/12/13 15:03:29 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/02 20:57:36 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:33:24 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/03/08 17:47:06 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:33:21 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,8 +17,6 @@ int put_job_in_foreground(t_job *j, int cont)
|
||||||
t_jobc *jobc;
|
t_jobc *jobc;
|
||||||
|
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
if (SH_HAS_JOBC(data_singleton()->opts))
|
|
||||||
{
|
|
||||||
tcsetpgrp(STDIN, j->pgid);
|
tcsetpgrp(STDIN, j->pgid);
|
||||||
if (cont)
|
if (cont)
|
||||||
{
|
{
|
||||||
|
|
@ -29,13 +27,10 @@ int put_job_in_foreground(t_job *j, int cont)
|
||||||
job_wait(j->id);
|
job_wait(j->id);
|
||||||
job_remove(j->id);
|
job_remove(j->id);
|
||||||
tcsetpgrp(STDIN, jobc->shell_pgid);
|
tcsetpgrp(STDIN, jobc->shell_pgid);
|
||||||
|
if (SH_HAS_JOBC(data_singleton()->opts))
|
||||||
|
{
|
||||||
tcgetattr(STDIN, &j->tmodes);
|
tcgetattr(STDIN, &j->tmodes);
|
||||||
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
|
tcsetattr(STDIN, TCSADRAIN, &jobc->shell_tmodes);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
job_wait(j->id);
|
|
||||||
job_remove(j->id);
|
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 15:51:17 by jhalford #+# #+# */
|
/* Created: 2017/03/08 15:51:17 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:52:41 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 18:11:11 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
|
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/08 17:21:36 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:57:05 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 14:39:07 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:56:47 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/08 13:04:03 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 20:56:52 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue