pull done

This commit is contained in:
Antoine Riard 2017-03-08 03:07:16 +01:00
commit cc5ba1dc75
9 changed files with 87 additions and 24 deletions

View file

@ -185,6 +185,10 @@ job-control/mark_job_as_running.c\
job-control/process_cmp_pid.c\ job-control/process_cmp_pid.c\
job-control/process_format.c\ job-control/process_format.c\
job-control/process_free.c\ job-control/process_free.c\
job-control/process_free_cmd.c\
job-control/process_free_cond.c\
job-control/process_free_list.c\
job-control/process_free_subshell.c\
job-control/put_job_in_background.c\ job-control/put_job_in_background.c\
job-control/put_job_in_foreground.c\ job-control/put_job_in_foreground.c\
job-control/sigchld_handler.c\ job-control/sigchld_handler.c\

View file

@ -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 01:48:29 by ariard ### ########.fr */ /* Updated: 2017/03/08 03:05:38 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -75,9 +75,8 @@ union u_process_data
struct s_data_cmd cmd; struct s_data_cmd cmd;
struct s_data_subshell subshell; struct s_data_subshell subshell;
struct s_data_cond d_while; struct s_data_cond d_while;
struct s_data_cond d_until;
struct s_data_cond d_if; struct s_data_cond d_if;
struct s_data_cond d_else;
struct s_data_cond d_elif;
struct s_data_list d_for; struct s_data_list d_for;
struct s_data_list d_case; struct s_data_list d_case;
}; };
@ -192,7 +191,10 @@ int error_badidentifier(char *name);
** Mapping pour free les process ** Mapping pour free les process
*/ */
void process_free(void *content, size_t content_size); void process_free(void *content, size_t content_size);
void process_free_cmd(t_process *p); int process_free_cmd(t_process *p);
int process_free_cond(t_process *p);
int process_free_list(t_process *p);
int process_free_subshell(t_process *p);
/* /*
** Mapping pour launch les process ** Mapping pour launch les process

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 22:04:42 by wescande #+# #+# */ /* Created: 2017/03/07 22:04:42 by wescande #+# #+# */
/* Updated: 2017/03/07 22:06:50 by wescande ### ########.fr */ /* Updated: 2017/03/08 02:35:09 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,13 +16,13 @@ static int do_until(t_process *p)
{ {
int ret; int ret;
ft_exec(&p->data.d_while.condition); ft_exec(&p->data.d_until.condition);
ret = ft_atoi(ft_getenv(data_singleton()->env, "?")); ret = ft_atoi(ft_getenv(data_singleton()->env, "?"));
while (ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0")) while (ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0"))
{ {
ft_exec(&p->data.d_while.content); ft_exec(&p->data.d_until.content);
ret = ft_atoi(ft_getenv(data_singleton()->env, "?")); ret = ft_atoi(ft_getenv(data_singleton()->env, "?"));
ft_exec(&p->data.d_while.condition); ft_exec(&p->data.d_until.condition);
} }
return (ret); return (ret);
} }

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 22:22:24 by wescande #+# #+# */ /* Created: 2017/03/07 22:22:24 by wescande #+# #+# */
/* Updated: 2017/03/08 01:54:37 by ariard ### ########.fr */ /* Updated: 2017/03/08 03:06:03 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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 02:06:04 by ariard ### ########.fr */ /* Updated: 2017/03/08 03:07:01 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,13 +16,13 @@ t_itof g_freemap[] =
{ {
{PROCESS_FUNCTION, NULL}, {PROCESS_FUNCTION, NULL},
{PROCESS_BUILTIN, NULL}, {PROCESS_BUILTIN, NULL},
{PROCESS_FILE, NULL}, {PROCESS_FILE, process_free_cmd},
{PROCESS_SUBSHELL, NULL}, {PROCESS_SUBSHELL, process_free_subshell},
{PROCESS_WHILE, NULL}, {PROCESS_WHILE, process_free_cond},
{PROCESS_UNTIL, NULL}, {PROCESS_UNTIL, process_free_cond},
{PROCESS_IF, NULL}, {PROCESS_IF, process_free_cond},
{PROCESS_FOR, NULL}, {PROCESS_FOR, process_free_list},
{PROCESS_CASE, NULL}, {PROCESS_CASE, process_free_list},
{0, NULL} {0, NULL}
}; };
@ -31,14 +31,11 @@ void process_free(void *content, size_t content_size)
t_process *p; t_process *p;
p = content; p = content;
DG();
(void)content_size; (void)content_size;
if (p->type >= PROCESS_MAX) if (p->type >= PROCESS_MAX)
return ; return ;
if (!g_freemap[p->type].f) if (g_freemap[p->type].f)
return ; (g_freemap[p->type].f)(p);
(g_freemap[p->type].f)(p);
ft_lstdel(&p->redirs, ft_lst_cfree); ft_lstdel(&p->redirs, ft_lst_cfree);
free(p); free(p);
DG();
} }

View file

@ -6,14 +6,15 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 00:58:02 by wescande #+# #+# */ /* Created: 2017/03/08 00:58:02 by wescande #+# #+# */
/* Updated: 2017/03/08 00:59:38 by wescande ### ########.fr */ /* Updated: 2017/03/08 02:31:01 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
void process_free_cmd(t_process *p) int process_free_cmd(t_process *p)
{ {
ft_strdel(&p->data.cmd.path); ft_strdel(&p->data.cmd.path);
ft_sstrfree(p->data.cmd.av); ft_sstrfree(p->data.cmd.av);
return (0);
} }

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_free_cond.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 02:26:31 by wescande #+# #+# */
/* Updated: 2017/03/08 02:39:12 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int process_free_cond(t_process *p)
{
btree_del(&p->data.d_while.condition, &ast_free);
btree_del(&p->data.d_while.content, &ast_free);
return (0);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_free_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 02:37:04 by wescande #+# #+# */
/* Updated: 2017/03/08 02:37:52 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int process_free_list(t_process *p)
{
ft_ld_del(&p->data.d_for.list_word, &ft_tabdel);
btree_del(&p->data.d_for.content, &ast_free);
return (0);
}

View file

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_free_subshell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 02:38:12 by wescande #+# #+# */
/* Updated: 2017/03/08 02:38:27 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int process_free_subshell(t_process *p)
{
btree_del(&p->data.d_while.content, &ast_free);
return (0);
}