"grammar better"
This commit is contained in:
Antoine Riard 2017-03-09 16:06:59 +01:00
commit 70372a4d85
15 changed files with 47 additions and 20 deletions

View file

@ -91,6 +91,7 @@ exec/mark_process_status.c\
exec/node_copy.c\ exec/node_copy.c\
exec/process_redirect.c\ exec/process_redirect.c\
exec/process_reset.c\ exec/process_reset.c\
exec/process_resetfds.c\
exec/process_setgroup.c\ exec/process_setgroup.c\
exec/process_setsig.c\ exec/process_setsig.c\
exec/redir_copy.c\ exec/redir_copy.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 19:15:13 by jhalford ### ########.fr */ /* Updated: 2017/03/09 15:14:34 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -136,7 +136,7 @@ int exec_reset(void);
int process_setgroup(t_process *p, pid_t pid); int process_setgroup(t_process *p, pid_t pid);
void process_setsig(void); void process_setsig(void);
void process_reset(t_process *p); void process_reset(t_process *p);
void process_resetfds(void); void process_resetfds(t_process *p);
int fd_is_valid(int fd, int flag); int fd_is_valid(int fd, int flag);
int bad_fd(int fd); int bad_fd(int fd);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */ /* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */
/* Updated: 2017/03/03 20:12:45 by wescande ### ########.fr */ /* Updated: 2017/03/09 14:58:10 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
/* Updated: 2017/03/09 14:35:20 by jhalford ### ########.fr */ /* Updated: 2017/03/09 15:14:37 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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 20:31:12 by jhalford ### ########.fr */ /* Updated: 2017/03/09 15:21:14 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */ /* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */
/* Updated: 2017/03/08 14:45:10 by jhalford ### ########.fr */ /* Updated: 2017/03/09 15:22:51 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,9 +17,9 @@ int exec_reset(void)
t_exec *exec; t_exec *exec;
exec = &data_singleton()->exec; exec = &data_singleton()->exec;
exec->fd_save[0] = fcntl(0, F_DUPFD_CLOEXEC); exec->fd_save[0] = fcntl(STDIN, F_DUPFD_CLOEXEC);
exec->fd_save[1] = fcntl(1, F_DUPFD_CLOEXEC); exec->fd_save[1] = fcntl(STDOUT, F_DUPFD_CLOEXEC);
exec->fd_save[2] = fcntl(2, F_DUPFD_CLOEXEC); exec->fd_save[2] = fcntl(STDERR, F_DUPFD_CLOEXEC);
exec->op_stack = NULL; exec->op_stack = NULL;
exec->fdin = STDIN; exec->fdin = STDIN;
exec->attrs = 0; exec->attrs = 0;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */ /* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
/* Updated: 2017/03/08 15:10:49 by wescande ### ########.fr */ /* Updated: 2017/03/09 15:12:48 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */ /* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
/* Updated: 2017/03/08 17:35:42 by jhalford ### ########.fr */ /* Updated: 2017/03/09 15:10:15 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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 23:43:18 by ariard ### ########.fr */ /* Updated: 2017/03/09 15:15:33 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -37,7 +37,11 @@ int launch_process(t_process *p)
p->attrs &= ~PROCESS_STATE_MASK; p->attrs &= ~PROCESS_STATE_MASK;
p->attrs |= PROCESS_RUNNING; p->attrs |= PROCESS_RUNNING;
if (!(pid = (*g_launchmap[p->type].f)(p))) if (!(pid = (*g_launchmap[p->type].f)(p)))
{
DG("gonna reset fds");
process_resetfds(p);
return (-1); return (-1);
}
p->pid = pid; p->pid = pid;
process_setgroup(p, pid); process_setgroup(p, pid);
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */ /* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2017/03/07 21:04:38 by wescande ### ########.fr */ /* Updated: 2017/03/09 15:14:43 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/07 17:44:22 by jhalford #+# #+# */ /* Created: 2017/02/07 17:44:22 by jhalford #+# #+# */
/* Updated: 2017/03/08 14:51:19 by jhalford ### ########.fr */ /* Updated: 2017/03/09 15:09:42 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_resetfds.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/09 14:51:23 by jhalford #+# #+# */
/* Updated: 2017/03/09 15:20:41 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void process_resetfds(t_process *p)
{
t_exec *exec;
(void)p;
exec = &data_singleton()->exec;
dup2(exec->fd_save[0], STDIN);
dup2(exec->fd_save[1], STDOUT);
dup2(exec->fd_save[2], STDERR);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 16:58:24 by jhalford #+# #+# */ /* Created: 2017/03/05 16:58:24 by jhalford #+# #+# */
/* Updated: 2017/03/09 14:32:07 by jhalford ### ########.fr */ /* Updated: 2017/03/09 14:53:42 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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 23:40:20 by ariard ### ########.fr */ /* Updated: 2017/03/09 15:23:31 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,15 +21,13 @@ int data_init(void)
data = data_singleton(); data = data_singleton();
data->env = ft_sstrdup(environ); data->env = ft_sstrdup(environ);
data->local_var = NULL;
set_exitstatus(0, 1); set_exitstatus(0, 1);
data->comp = NULL; data->comp = NULL;
data->opts = 0; data->opts = 0;
exec_reset(); exec_reset();
data->jobc.first_job = NULL; data->jobc.first_job = NULL;
data->jobc.current_id = 1; data->jobc.current_id = 1;
data->local_var = NULL;
data->lst_func = NULL; data->lst_func = NULL;
data->heredoc_queue = NULL; data->heredoc_queue = NULL;
if ((term_name = ft_getenv(data->env, "TERM")) == NULL) if ((term_name = ft_getenv(data->env, "TERM")) == NULL)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/10 11:36:39 by jhalford #+# #+# */ /* Created: 2017/01/10 11:36:39 by jhalford #+# #+# */
/* Updated: 2017/03/08 20:50:57 by ariard ### ########.fr */ /* Updated: 2017/03/09 15:22:54 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */