modifs var
This commit is contained in:
commit
dc1662f754
15 changed files with 50 additions and 66 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 22:36:52 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:02:23 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ struct s_data_list
|
|||
t_btree *content;
|
||||
};
|
||||
|
||||
struct s_data_subshell
|
||||
struct s_data_tree
|
||||
{
|
||||
t_btree *content;
|
||||
};
|
||||
|
|
@ -74,9 +74,9 @@ struct s_data_subshell
|
|||
union u_process_data
|
||||
{
|
||||
struct s_data_cmd cmd;
|
||||
struct s_data_subshell subshell;
|
||||
struct s_data_subshell brace;
|
||||
struct s_data_subshell function;
|
||||
struct s_data_tree subshell;
|
||||
struct s_data_tree brace;
|
||||
struct s_data_tree function;
|
||||
struct s_data_cond d_while;
|
||||
struct s_data_cond d_until;
|
||||
struct s_data_cond d_if;
|
||||
|
|
@ -133,9 +133,6 @@ struct s_exec
|
|||
int control_count;
|
||||
};
|
||||
|
||||
/* extern t_itof g_redirmap[]; */
|
||||
/* extern t_itof g_execmap[]; */
|
||||
|
||||
int exec_reset(void);
|
||||
int process_setgroup(t_process *p, pid_t pid);
|
||||
void process_setsig(void);
|
||||
|
|
@ -164,10 +161,10 @@ void redir_free(void *data, size_t content_size);
|
|||
|
||||
char **token_to_argv(t_ld *ld, int do_match);
|
||||
|
||||
int add_new_job(t_job *job);
|
||||
/* int add_new_job(t_job *job); */
|
||||
|
||||
int error_badidentifier(char *name);
|
||||
t_btree *is_function(t_process *p);
|
||||
t_btree *is_function(t_process *p);
|
||||
|
||||
/*
|
||||
** Mapping pour free les process
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/07 19:42:54 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/13 22:52:32 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/13 22:37:51 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:56:53 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -35,11 +35,9 @@ int exec_leaf(t_btree **ast)
|
|||
job = &data_singleton()->exec.job;
|
||||
if (process_set(&p, *ast))
|
||||
return (1);
|
||||
DG("p.type=%i", p.type);
|
||||
p.map = g_process_map[p.type];
|
||||
if (!(process_launch(&p)))
|
||||
{
|
||||
DG("check");
|
||||
DG("forked pid=[%i]", p.pid);
|
||||
job_addprocess(&p);
|
||||
/* DG("[IS_BG->%i]", JOB_IS_BG(job->attrs)); */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 10:58:49 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/13 23:59:50 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/14 00:55:04 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/13 19:09:30 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 20:28:57 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/14 00:04:09 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,11 +14,14 @@
|
|||
|
||||
int plaunch_brace(t_process *p)
|
||||
{
|
||||
if (process_redirect(p))
|
||||
if (IS_PIPESINGLE(*p))
|
||||
{
|
||||
set_exitstatus(1, 1);
|
||||
if (process_redirect(p))
|
||||
set_exitstatus(1, 1);
|
||||
else
|
||||
ft_exec(&p->data.brace.content);
|
||||
return (0);
|
||||
}
|
||||
ft_exec(&p->data.subshell.content);
|
||||
return (0);
|
||||
else
|
||||
return (plaunch_subshell(p));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 20:28:57 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:35:37 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,11 +29,12 @@ int plaunch_builtin(t_process *p)
|
|||
pid = fork();
|
||||
if (pid == 0)
|
||||
{
|
||||
process_setgroup(p, 0);
|
||||
process_setsig();
|
||||
if (process_redirect(p))
|
||||
exit (1);
|
||||
process_setgroup(p, 0);
|
||||
process_setsig();
|
||||
exec_reset();///A FAIRE POUR LES BUILTIN OU PAS ? -> Q de William
|
||||
// je pense ca ne change rien si on l'enleve car on excve apres
|
||||
exit((*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env));
|
||||
}
|
||||
else if (pid > 0)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 22:39:43 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:15:06 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ int plaunch_file(t_process *p)
|
|||
{
|
||||
/* data_singleton()->opts &= ~SH_INTERACTIVE; */
|
||||
/* data_singleton()->opts &= ~SH_OPTS_JOBC; */
|
||||
/* DG("fork! [%s]", p->data.cmd.av[0]); */
|
||||
DG("fork! [%s]", p->data.cmd.av[0]);
|
||||
if (process_redirect(p))
|
||||
exit (1);
|
||||
process_setgroup(p, 0);
|
||||
|
|
|
|||
|
|
@ -6,47 +6,32 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/13 20:28:57 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/14 00:00:26 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
static int do_subshell(t_process *p)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ft_exec(&p->data.subshell.content);
|
||||
ret = ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
||||
DG("CHECK, ret=[%i]", ret);
|
||||
/* p = ft_lstlast(j->first_process)->content; */
|
||||
/* ret = p->status */
|
||||
/* DG("CHECK, ret=[%i]", ret); */
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int plaunch_subshell(t_process *p)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
pid = fork();
|
||||
if (pid == 0)
|
||||
{
|
||||
pid = fork();
|
||||
if (pid == 0)
|
||||
{
|
||||
data_singleton()->opts &= ~SH_INTERACTIVE;
|
||||
data_singleton()->opts &= ~SH_OPTS_JOBC;
|
||||
if (process_redirect(p))
|
||||
exit (1);
|
||||
process_setgroup(p, 0);
|
||||
process_setsig();
|
||||
exec_reset();
|
||||
exit(do_subshell(p));
|
||||
}
|
||||
else if (pid > 0)
|
||||
return (pid);
|
||||
data_singleton()->opts &= ~SH_INTERACTIVE;
|
||||
data_singleton()->opts &= ~SH_OPTS_JOBC;
|
||||
if (process_redirect(p))
|
||||
exit (1);
|
||||
process_setgroup(p, 0);
|
||||
process_setsig();
|
||||
exec_reset();
|
||||
ft_exec(&p->data.subshell.content);
|
||||
exit(ft_atoi(ft_getenv(data_singleton()->env, "?")));
|
||||
}
|
||||
else
|
||||
do_subshell(p);
|
||||
else if (pid > 0)
|
||||
return (pid);
|
||||
else if (pid == -1)
|
||||
ft_dprintf(2, "{red}%s: internal fork error{eoc}\n", SHELL_NAME);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 22:35:24 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:10:42 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -40,10 +40,11 @@ int process_launch(t_process *p)
|
|||
p->attrs |= PROCESS_RUNNING;
|
||||
if (!(pid = (*p->map.launch)(p)))
|
||||
{
|
||||
DG("launcher did not fork!");
|
||||
process_resetfds(p);
|
||||
return (1);
|
||||
}
|
||||
DG("launcher did not fork!");
|
||||
DG("launcher forked!");
|
||||
p->pid = pid;
|
||||
process_setgroup(p, pid);
|
||||
if (p->fdin != STDIN)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 22:39:48 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 22:40:00 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 13:37:03 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:33:06 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:06:05 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/13 20:31:21 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 22:52:43 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 23:41:15 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/14 00:54:47 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/12 14:01:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 22:25:13 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:32:52 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,7 +30,6 @@
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
static t_btree *gen_t_btree(const char *command)
|
||||
{
|
||||
t_btree *ast;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/13 22:50:49 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/13 23:58:56 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ int handle_instruction(int fd)
|
|||
if (parser.state == ERROR)
|
||||
error_syntax(&token, &parser, &ast);
|
||||
lexer.state = data_singleton()->heredoc_queue ? HEREDOC : 0;
|
||||
DG("lexer.state=%i", lexer.state);
|
||||
/* DG("lexer.state=%i", lexer.state); */
|
||||
if (lexer.state)
|
||||
continue;
|
||||
else if (parser.state == SUCCESS)
|
||||
|
|
|
|||
Loading…
Reference in a new issue