debut mise a la norme exec
This commit is contained in:
parent
88598b049a
commit
aa042a4e37
36 changed files with 131 additions and 164 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* exec_and_if.c :+: :+: :+: */
|
/* exec_and_if.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/30 20:52:28 by jhalford #+# #+# */
|
/* Created: 2016/11/30 20:52:28 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/10 14:26:32 by ariard ### ########.fr */
|
/* Updated: 2017/03/20 15:40:02 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
int exec_and_if(t_btree **ast)
|
int exec_and_if(t_btree **ast)
|
||||||
{
|
{
|
||||||
/* t_data *data; */
|
|
||||||
t_exec *exec;
|
t_exec *exec;
|
||||||
|
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
|
|
@ -23,24 +22,5 @@ int exec_and_if(t_btree **ast)
|
||||||
exec->attrs &= ~EXEC_OR_IF;
|
exec->attrs &= ~EXEC_OR_IF;
|
||||||
exec->attrs |= EXEC_AND_IF;
|
exec->attrs |= EXEC_AND_IF;
|
||||||
ft_exec(&(*ast)->right);
|
ft_exec(&(*ast)->right);
|
||||||
|
|
||||||
/* data = data_singleton(); */
|
|
||||||
/* if (data->exec.aol_status == NULL */
|
|
||||||
/* || (data->exec.aol_search == TK_AND_IF */
|
|
||||||
/* && *data->exec.aol_status == '0') */
|
|
||||||
/* || (data->exec.aol_search == TK_OR_IF */
|
|
||||||
/* && *data->exec.aol_status != '0')) */
|
|
||||||
/* { */
|
|
||||||
/* ft_exec(&(*ast)->left); */
|
|
||||||
/* data->exec.aol_status = ft_getenv(data->env, "?"); */
|
|
||||||
/* } */
|
|
||||||
/* data->exec.aol_search = TK_AND_IF; */
|
|
||||||
/* if (*data->exec.aol_status == '0' */
|
|
||||||
/* || ((t_astnode*)(*ast)->right->item)->type != TK_COMMAND) */
|
|
||||||
/* ft_exec(&(*ast)->right); */
|
|
||||||
/* data->exec.aol_status = NULL; */
|
|
||||||
/* data->exec.aol_search = 0; */
|
|
||||||
|
|
||||||
// btree_delone(ast, &ast_free);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/10 14:46:27 by ariard #+# #+# */
|
/* Created: 2017/03/10 14:46:27 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/10 16:25:35 by ariard ### ########.fr */
|
/* Updated: 2017/03/20 15:41:04 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 20:33:45 by wescande #+# #+# */
|
/* Created: 2017/03/07 20:33:45 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/15 01:21:45 by ariard ### ########.fr */
|
/* Updated: 2017/03/20 15:42:17 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,19 +18,15 @@ int exec_case_branch(t_btree **ast)
|
||||||
char **av;
|
char **av;
|
||||||
t_exec *exec;
|
t_exec *exec;
|
||||||
|
|
||||||
DG("exec branch case");
|
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
if (EXEC_IS_CASE_BRANCH(exec->attrs))
|
if (EXEC_IS_CASE_BRANCH(exec->attrs))
|
||||||
return (0);
|
return (0);
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
av = token_to_argv(node->data.cmd.token, 1);
|
av = token_to_argv(node->data.cmd.token, 1);
|
||||||
DG("compare pattern %s ", av[0]);
|
|
||||||
DG("and case %s", ((char **)exec->case_pattern)[0]);
|
|
||||||
DG();
|
|
||||||
if (ft_strcmp(av[0], ((char **)exec->case_pattern)[0]) == 0)
|
if (ft_strcmp(av[0], ((char **)exec->case_pattern)[0]) == 0)
|
||||||
{
|
{
|
||||||
exec->attrs |= EXEC_CASE_BRANCH;
|
exec->attrs |= EXEC_CASE_BRANCH;
|
||||||
ft_exec(&(*ast)->right);
|
ft_exec(&(*ast)->right);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* exec_or_if.c :+: :+: :+: */
|
/* exec_or_if.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/30 21:06:17 by jhalford #+# #+# */
|
/* Created: 2016/11/30 21:06:17 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/05 15:18:49 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:40:15 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
int exec_or_if(t_btree **ast)
|
int exec_or_if(t_btree **ast)
|
||||||
{
|
{
|
||||||
/* t_data *data; */
|
|
||||||
t_exec *exec;
|
t_exec *exec;
|
||||||
|
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
|
|
@ -23,24 +22,5 @@ int exec_or_if(t_btree **ast)
|
||||||
exec->attrs &= ~EXEC_AND_IF;
|
exec->attrs &= ~EXEC_AND_IF;
|
||||||
exec->attrs = EXEC_OR_IF;
|
exec->attrs = EXEC_OR_IF;
|
||||||
ft_exec(&(*ast)->right);
|
ft_exec(&(*ast)->right);
|
||||||
|
|
||||||
/* data = data_singleton(); */
|
|
||||||
/* if (data->exec.aol_status == NULL */
|
|
||||||
/* || (data->exec.aol_search == TK_AND_IF */
|
|
||||||
/* && *data->exec.aol_status == '0') */
|
|
||||||
/* || (data->exec.aol_search == TK_OR_IF */
|
|
||||||
/* && *data->exec.aol_status != '0')) */
|
|
||||||
/* { */
|
|
||||||
/* ft_exec(&(*ast)->left); */
|
|
||||||
/* data->exec.aol_status = ft_getenv(data->env, "?"); */
|
|
||||||
/* } */
|
|
||||||
/* data->exec.aol_search = TK_OR_IF; */
|
|
||||||
/* if (*data->exec.aol_status != '0' */
|
|
||||||
/* || ((t_astnode*)(*ast)->right->item)->type != TK_COMMAND) */
|
|
||||||
/* ft_exec(&(*ast)->right); */
|
|
||||||
/* data->exec.aol_status = NULL; */
|
|
||||||
/* data->exec.aol_search = 0; */
|
|
||||||
|
|
||||||
// btree_delone(ast, &ast_free);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* exec_pipe.c :+: :+: :+: */
|
/* exec_pipe.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */
|
/* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/03 16:27:48 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:42:40 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,6 +20,5 @@ int exec_pipe(t_btree **ast)
|
||||||
push(&exec->op_stack, TK_PIPE);
|
push(&exec->op_stack, TK_PIPE);
|
||||||
ft_exec(&(*ast)->left);
|
ft_exec(&(*ast)->left);
|
||||||
ft_exec(&(*ast)->right);
|
ft_exec(&(*ast)->right);
|
||||||
/* btree_delone(ast, &ast_free); */
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,28 +3,37 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* exec_reset.c :+: :+: :+: */
|
/* exec_reset.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 11:35:49 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:09:02 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int exec_reset(void)
|
static void print_error(char *std)
|
||||||
|
{
|
||||||
|
ft_dprintf(2, "{red}%s: internal fcntl %s error errno=%i{eoc}\n",
|
||||||
|
SHELL_NAME, std, errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
int exec_reset(void)
|
||||||
{
|
{
|
||||||
t_exec *exec;
|
t_exec *exec;
|
||||||
t_jobc *jobc;
|
t_jobc *jobc;
|
||||||
|
|
||||||
exec = &data_singleton()->exec;
|
exec = &data_singleton()->exec;
|
||||||
jobc = &data_singleton()->jobc;
|
jobc = &data_singleton()->jobc;
|
||||||
if ((exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF)
|
if (errno != EBADF)
|
||||||
ft_dprintf(2, "{red}%s: internal fcntl STDIN error errno=%i{eoc}\n", SHELL_NAME, errno);
|
{
|
||||||
if ((exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF)
|
if ((exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC, 10)) == -1)
|
||||||
ft_dprintf(2, "{red}%s: internal fcntl STDOUT error errno=%i{eoc}\n", SHELL_NAME, errno);
|
print_error("STDIN");
|
||||||
if ((exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC, 10)) == -1 && errno != EBADF)
|
if ((exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC, 10)) == -1)
|
||||||
ft_dprintf(2, "{red}%s: internal fcntl STDERR error errno=%i{eoc}\n", SHELL_NAME, errno);
|
print_error("STDOUT");
|
||||||
|
if ((exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC, 10)) == -1)
|
||||||
|
print_error("STDERR");
|
||||||
|
}
|
||||||
exec->op_stack = NULL;
|
exec->op_stack = NULL;
|
||||||
exec->fdin = STDIN;
|
exec->fdin = STDIN;
|
||||||
exec->attrs = 0;
|
exec->attrs = 0;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 11:12:05 by ariard #+# #+# */
|
/* Created: 2017/03/07 11:12:05 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/14 23:55:40 by ariard ### ########.fr */
|
/* Updated: 2017/03/20 15:43:34 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ static int set_var(char *stream, char **var, char **value)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int exec_var(t_btree **ast)
|
int exec_var(t_btree **ast)
|
||||||
{
|
{
|
||||||
t_astnode *node;
|
t_astnode *node;
|
||||||
char **av;
|
char **av;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 03:38:36 by wescande #+# #+# */
|
/* Created: 2017/03/08 03:38:36 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/20 14:06:47 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:51:07 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -30,8 +30,8 @@ void *node_copy(void *data)
|
||||||
new->data.cmd.redir = ft_lstmap(old->data.cmd.redir, &redir_copy);
|
new->data.cmd.redir = ft_lstmap(old->data.cmd.redir, &redir_copy);
|
||||||
new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
|
new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
|
||||||
}
|
}
|
||||||
if (old->type == TK_FOR || old->type == TK_PAREN_OPEN || old->type == TK_CASE
|
if (old->type == TK_FOR || old->type == TK_PAREN_OPEN
|
||||||
|| old->type == FNAME)
|
|| old->type == TK_CASE || old->type == FNAME)
|
||||||
new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
|
new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
|
||||||
return (new);
|
return (new);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pfree_cmd.c :+: :+: :+: */
|
/* pfree_cmd.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* 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/13 22:31:32 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:50:07 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pfree_cond.c :+: :+: :+: */
|
/* pfree_cond.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 02:26:31 by wescande #+# #+# */
|
/* Created: 2017/03/08 02:26:31 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/15 02:04:14 by ariard ### ########.fr */
|
/* Updated: 2017/03/20 15:49:52 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pfree_list.c :+: :+: :+: */
|
/* pfree_list.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 02:37:04 by wescande #+# #+# */
|
/* Created: 2017/03/08 02:37:04 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/15 01:05:43 by ariard ### ########.fr */
|
/* Updated: 2017/03/20 15:50:03 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pfree_subshell.c :+: :+: :+: */
|
/* pfree_subshell.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 02:38:12 by wescande #+# #+# */
|
/* Created: 2017/03/08 02:38:12 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/13 22:31:26 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:50:05 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_brace.c :+: :+: :+: */
|
/* plaunch_brace.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/13 19:09:30 by jhalford #+# #+# */
|
/* Created: 2017/03/13 19:09:30 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:35:24 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:10 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_builtin.c :+: :+: :+: */
|
/* plaunch_builtin.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
|
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:22:12 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:12 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_case.c :+: :+: :+: */
|
/* plaunch_case.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 19:02:23 by wescande #+# #+# */
|
/* Created: 2017/03/07 19:02:23 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:17:07 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:14 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* process_empty.c :+: :+: :+: */
|
/* plaunch_empty.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/13 17:26:01 by jhalford #+# #+# */
|
/* Created: 2017/03/13 17:26:01 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:23:18 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:16 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,4 +17,3 @@ int plaunch_empty(t_process *p)
|
||||||
(void)p;
|
(void)p;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_file.c :+: :+: :+: */
|
/* plaunch_file.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:22:38 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:17 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/15 00:49:20 by wescande #+# #+# */
|
/* Created: 2017/03/15 00:49:20 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:16:46 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:51:47 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ int plaunch_for(t_process *p)
|
||||||
av = token_to_argv(temp, 1);
|
av = token_to_argv(temp, 1);
|
||||||
while (av[++i])
|
while (av[++i])
|
||||||
{
|
{
|
||||||
builtin_setenv("setenv", (char*[]){"local" ,var, av[i], 0},
|
builtin_setenv("setenv", (char*[]){"local", var, av[i], 0},
|
||||||
NULL);
|
NULL);
|
||||||
ft_exec(&p->data.d_for.content);
|
ft_exec(&p->data.d_for.content);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_function.c :+: :+: :+: */
|
/* plaunch_function.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 03:23:59 by wescande #+# #+# */
|
/* Created: 2017/03/08 03:23:59 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:29:36 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:21 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_if.c :+: :+: :+: */
|
/* plaunch_if.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 17:26:53 by wescande #+# #+# */
|
/* Created: 2017/03/07 17:26:53 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:30:36 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:23 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_subshell.c :+: :+: :+: */
|
/* plaunch_subshell.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
|
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/17 20:28:08 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:25 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_until.c :+: :+: :+: */
|
/* plaunch_until.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* 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/18 01:52:33 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:27 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* plaunch_while.c :+: :+: :+: */
|
/* plaunch_while.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 17:20:53 by wescande #+# #+# */
|
/* Created: 2017/03/07 17:20:53 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/18 01:48:53 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:50:29 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* process_launch.c :+: :+: :+: */
|
/* process_launch.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 14:57:26 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:58:12 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int do_the_muther_forker(t_process *p)
|
int do_the_muther_forker(t_process *p)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
|
@ -25,9 +25,8 @@ int do_the_muther_forker(t_process *p)
|
||||||
return (pid);
|
return (pid);
|
||||||
if (!p)
|
if (!p)
|
||||||
return (pid);
|
return (pid);
|
||||||
DG("START OF FORK");
|
|
||||||
if (process_redirect(p))
|
if (process_redirect(p))
|
||||||
exit (1);
|
exit(1);
|
||||||
process_setgroup(p, 0);
|
process_setgroup(p, 0);
|
||||||
process_setsig();
|
process_setsig();
|
||||||
exec_reset();
|
exec_reset();
|
||||||
|
|
@ -51,19 +50,16 @@ static int do_the_fork_if_i_have_to(t_process *p)
|
||||||
return (do_the_muther_forker(p));
|
return (do_the_muther_forker(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_launch(t_process *p)
|
int process_launch(t_process *p)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
DG("p->type=%i", p->type);
|
|
||||||
p->state = PROCESS_RUNNING;
|
p->state = PROCESS_RUNNING;
|
||||||
if (!(pid = do_the_fork_if_i_have_to(p)))
|
if (!(pid = do_the_fork_if_i_have_to(p)))
|
||||||
{
|
{
|
||||||
DG("launcher did not fork!");
|
|
||||||
process_resetfds(p);
|
process_resetfds(p);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
DG("launcher forked! with : %d ", pid);
|
|
||||||
p->pid = pid;
|
p->pid = pid;
|
||||||
process_setgroup(p, pid);
|
process_setgroup(p, pid);
|
||||||
if (p->fdin != STDIN)
|
if (p->fdin != STDIN)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* process_redirect.c :+: :+: :+: */
|
/* process_redirect.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
|
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/16 23:28:44 by ariard ### ########.fr */
|
/* Updated: 2017/03/20 15:57:02 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,36 +23,36 @@ t_itof g_redirmap[] =
|
||||||
{0, NULL},
|
{0, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
int process_redirect(t_process *p)
|
static void process_close(int fd1, int fd2)
|
||||||
|
{
|
||||||
|
if (fd1 != fd2)
|
||||||
|
close(fd1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int process_redirect(t_process *p)
|
||||||
{
|
{
|
||||||
t_list *redirs;
|
t_list *redirs;
|
||||||
t_redir *redir;
|
t_redir *redir;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
redirs = p->redirs;
|
redirs = p->redirs;
|
||||||
if (p->to_close != STDIN)
|
process_close(p->to_close, STDIN);
|
||||||
close(p->to_close);
|
|
||||||
while (redirs)
|
while (redirs)
|
||||||
{
|
{
|
||||||
redir = redirs->content;
|
redir = redirs->content;
|
||||||
if (redir->n > 9)
|
if (redir->n > 9)
|
||||||
return (bad_fd(redir->n));
|
return (bad_fd(redir->n));
|
||||||
i = 0;
|
i = -1;
|
||||||
while (g_redirmap[i].id)
|
while (g_redirmap[++i].id)
|
||||||
{
|
|
||||||
if (g_redirmap[i].id == redir->type)
|
if (g_redirmap[i].id == redir->type)
|
||||||
{
|
{
|
||||||
if ((g_redirmap[i].f)(redir))
|
if ((g_redirmap[i].f)(redir))
|
||||||
return (1);
|
return (1);
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
|
||||||
redirs = redirs->next;
|
redirs = redirs->next;
|
||||||
}
|
}
|
||||||
if (p->fdin != STDIN)
|
process_close(p->fdin, STDIN);
|
||||||
dup2_close(p->fdin, STDIN);
|
process_close(p->fdout, STDOUT);
|
||||||
if (p->fdout != STDOUT)
|
|
||||||
dup2_close(p->fdout, STDOUT);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* set_process.c :+: :+: :+: */
|
/* process_set.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
|
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 12:51:06 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:02:08 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ int process_set(t_process *p, t_btree *ast)
|
||||||
&& ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0") != 0)
|
&& ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0") != 0)
|
||||||
|| (EXEC_IS_OR_IF(exec->attrs)
|
|| (EXEC_IS_OR_IF(exec->attrs)
|
||||||
&& ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0") == 0))
|
&& ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0") == 0))
|
||||||
return (1);
|
return (1);
|
||||||
fds[PIPE_WRITE] = STDOUT;
|
fds[PIPE_WRITE] = STDOUT;
|
||||||
fds[PIPE_READ] = STDIN;
|
fds[PIPE_READ] = STDIN;
|
||||||
if (op == TK_PIPE)
|
if (op == TK_PIPE)
|
||||||
|
|
@ -69,6 +69,7 @@ int process_set(t_process *p, t_btree *ast)
|
||||||
exec->fdin = fds[PIPE_READ];
|
exec->fdin = fds[PIPE_READ];
|
||||||
if (!ast)
|
if (!ast)
|
||||||
return (0);
|
return (0);
|
||||||
p->redirs = ft_lstmap(((t_astnode *)ast->item)->data.cmd.redir, &redir_copy);
|
p->redirs = ft_lstmap(((t_astnode *)ast->item)->data.cmd.redir,
|
||||||
|
&redir_copy);
|
||||||
return (process_set_spec(p, ast));
|
return (process_set_spec(p, ast));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* process_setgroup.c :+: :+: :+: */
|
/* process_setgroup.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
/* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/19 14:04:57 by wescande ### ########.fr */
|
/* Updated: 2017/03/20 15:58:33 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,15 +23,10 @@ int process_setgroup(t_process *p, pid_t pid)
|
||||||
j = &data->exec.job;
|
j = &data->exec.job;
|
||||||
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||||
return (0);
|
return (0);
|
||||||
DG("setpgid(%i, %i)", pid, j->pgid);
|
|
||||||
if (setpgid(pid, j->pgid) == -1)
|
if (setpgid(pid, j->pgid) == -1)
|
||||||
ft_dprintf(2, "{red}%s: internal setpgid() errno=%i{eoc}\n", SHELL_NAME, errno);
|
ft_dprintf(2, "{red}%s: internal setpgid() errno=%i{eoc}\n",
|
||||||
/* if (JOB_IS_FG(j->attrs)) */
|
SHELL_NAME, errno);
|
||||||
if (pid == 0 && JOB_IS_FG(j->attrs))
|
if (pid == 0 && JOB_IS_FG(j->attrs))
|
||||||
{
|
|
||||||
DG("tcsetpgrp[%i]", j->pgid);
|
|
||||||
tcsetpgrp(STDIN, j->pgid);
|
tcsetpgrp(STDIN, j->pgid);
|
||||||
DG("after tcsetpgrp");
|
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pset_brace.c :+: :+: :+: */
|
/* pset_brace.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/13 19:07:34 by jhalford #+# #+# */
|
/* Created: 2017/03/13 19:07:34 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 10:29:06 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:58:50 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int pset_brace(t_process *p, t_btree *ast)
|
int pset_brace(t_process *p, t_btree *ast)
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pset_case.c :+: :+: :+: */
|
/* pset_case.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 20:36:04 by wescande #+# #+# */
|
/* Created: 2017/03/07 20:36:04 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/20 10:27:59 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:59:05 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
int pset_case(t_process *p, t_btree *ast)
|
int pset_case(t_process *p, t_btree *ast)
|
||||||
{
|
{
|
||||||
DG("set case");
|
p->data.d_case.token = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.token,
|
||||||
p->data.d_case.token = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.token, tab_esc_copy);
|
tab_esc_copy);
|
||||||
p->data.d_case.content = btree_map(ast->right, &node_copy);
|
p->data.d_case.content = btree_map(ast->right, &node_copy);
|
||||||
p->type = PROCESS_CASE;
|
p->type = PROCESS_CASE;
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pset_for.c :+: :+: :+: */
|
/* pset_for.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 19:38:05 by wescande #+# #+# */
|
/* Created: 2017/03/07 19:38:05 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/20 10:28:13 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 15:59:25 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
int pset_for(t_process *p, t_btree *ast)
|
int pset_for(t_process *p, t_btree *ast)
|
||||||
{
|
{
|
||||||
p->data.d_for.token = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.token, tab_esc_copy);
|
p->data.d_for.token = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.token,
|
||||||
|
tab_esc_copy);
|
||||||
p->data.d_for.content = btree_map(ast->right, &node_copy);
|
p->data.d_for.content = btree_map(ast->right, &node_copy);
|
||||||
p->type = PROCESS_FOR;
|
p->type = PROCESS_FOR;
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pset_if.c :+: :+: :+: */
|
/* pset_if.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/07 19:19:50 by wescande #+# #+# */
|
/* Created: 2017/03/07 19:19:50 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/20 10:27:36 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:26:35 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pset_sub.c :+: :+: :+: */
|
/* pset_subshell.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 00:02:01 by wescande #+# #+# */
|
/* Created: 2017/03/08 00:02:01 by wescande #+# #+# */
|
||||||
/* Updated: 2017/03/20 12:39:37 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:26:37 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* pset_until.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/20 16:26:43 by gwojda #+# #+# */
|
||||||
|
/* Updated: 2017/03/20 16:26:44 by gwojda ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int pset_until(t_process *p, t_btree *ast)
|
int pset_until(t_process *p, t_btree *ast)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* pset_while.c :+: :+: :+: */
|
/* pset_while.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 12:39:07 by jhalford #+# #+# */
|
/* Created: 2017/03/20 12:39:07 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 12:39:08 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:26:47 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/08 00:02:58 by ariard #+# #+# */
|
/* Created: 2017/03/08 00:02:58 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/20 12:21:26 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:26:50 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/03 18:12:57 by ariard #+# #+# */
|
/* Created: 2017/03/03 18:12:57 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/20 12:38:53 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 16:26:51 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue