diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index abe37ef9..e64a2aac 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2016/12/12 18:02:49 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:56:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 2e01ebf4..12b13b54 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2016/12/12 17:51:54 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:57:25 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,8 @@ # include # include "libft.h" +# define TYPE_BUILTIN + typedef struct s_job t_job; typedef struct s_jobc t_jobc; @@ -24,15 +26,20 @@ struct s_job { int id; pid_t pid; + int fdin; + int fdout; char *command; + t_type type; }; struct s_jobc { - t_list *list; + t_list *first_job; pid_t shell_pgid; int current_id; int rank[2]; + t_job job; + t_process process; struct termios shell_tmodes; }; diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index d4f3887d..7cbe29cc 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2016/12/12 17:56:30 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:56:56 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index 868612d2..bdc592f5 100644 --- a/42sh/src/exec/exec_command.c +++ b/42sh/src/exec/exec_command.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ -/* Updated: 2016/12/12 18:01:19 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:35:12 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,8 @@ int exec_command(t_btree **ast) t_astnode *node; node = (*ast)->item; + ft_strappend(&data->jobc.process.command, ft_sstrcat(node->data.sstr)); + DG("gonna exec_command '%s'", data->joc.process.command); ft_cmd_process(node->data.sstr); btree_delone(ast, &ast_free); return (0); diff --git a/42sh/src/exec/exec_less.c b/42sh/src/exec/exec_less.c index 2cd7639e..fca7b1e0 100644 --- a/42sh/src/exec/exec_less.c +++ b/42sh/src/exec/exec_less.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:27:08 by jhalford #+# #+# */ -/* Updated: 2016/12/12 18:03:52 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:24:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,12 +16,16 @@ int exec_less(t_btree **ast) { t_astnode *node; int fd; + t_data *data; node = (*ast)->item; fd = open(node->data.redir.word.word, O_RDONLY); - data_singleton()->exec.fdin = fd; + data_singleton()->jobc.process.fdin = fd; + ft_strappend(&data->jobc.process.command, "<"); + ft_strappend(&data->jobc.process.command, node->data.redir.word.word); ft_exec(&(*ast)->left); - data_singleton()->exec.fdin = STDIN; + data_singleton()->jobc.process.fdin = STDIN; + data->jobc.process.command = NULL; btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_pipe.c b/42sh/src/exec/exec_pipe.c index cac0e63e..2f558fa6 100644 --- a/42sh/src/exec/exec_pipe.c +++ b/42sh/src/exec/exec_pipe.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */ -/* Updated: 2016/12/12 18:04:20 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:31:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,17 +20,17 @@ int exec_pipe(t_btree **ast) data = data_singleton(); pipe(fds); DG("pipe %i->%i", fds[PIPE_WRITE], fds[PIPE_READ]); - data->exec.fdout = fds[PIPE_WRITE]; + data->jobc.process.fdout = fds[PIPE_WRITE]; ft_exec(&(*ast)->left); - if (data->exec.fdout != STDOUT) + if (data->jobc.process.fdout != STDOUT) close(data->exec.fdout); - data->exec.fdout = STDOUT; - data->exec.fdin = fds[PIPE_READ]; + data->jobc.process.fdout = STDOUT; + data->jobc.process.fdin = fds[PIPE_READ]; ft_exec(&(*ast)->right); close(fds[PIPE_WRITE]); close(fds[PIPE_READ]); - data->exec.fdin = STDIN; - data->exec.fdout = STDOUT; + data->jobc.process.fdin = STDIN; + data->jobc.process.fdout = STDOUT; btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/fd_redirect.c b/42sh/src/exec/fd_redirect.c index 5480b866..07ace92e 100644 --- a/42sh/src/exec/fd_redirect.c +++ b/42sh/src/exec/fd_redirect.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */ -/* Updated: 2016/12/12 17:54:45 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:13:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/ft_cmd.c b/42sh/src/exec/ft_cmd.c index 9dc9e546..08e1aa91 100644 --- a/42sh/src/exec/ft_cmd.c +++ b/42sh/src/exec/ft_cmd.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 21:13:18 by jhalford #+# #+# */ -/* Updated: 2016/12/12 18:11:05 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:56:18 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/job_new.c b/42sh/src/job-control/job_new.c index 66717f66..b01d41c3 100644 --- a/42sh/src/job-control/job_new.c +++ b/42sh/src/job-control/job_new.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:51:54 by jhalford #+# #+# */ -/* Updated: 2016/12/12 15:06:23 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 11:53:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/data_singleton.c b/42sh/src/main/data_singleton.c index c6139721..b5f87bbd 100644 --- a/42sh/src/main/data_singleton.c +++ b/42sh/src/main/data_singleton.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* data_singleton.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/12/13 11:19:51 by jhalford #+# #+# */ +/* Updated: 2016/12/13 11:52:47 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "minishell.h" t_data *data_singleton() diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index a6127a06..dd328da2 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2016/12/12 18:11:55 by jhalford ### ########.fr */ +/* Updated: 2016/12/13 12:05:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */