stuff i did before pulling
This commit is contained in:
parent
6cfac2eaff
commit
160810b3bc
11 changed files with 44 additions and 19 deletions
|
|
@ -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: 2016/12/12 18:02:49 by jhalford ### ########.fr */
|
/* Updated: 2016/12/13 12:56:42 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 16:55:09 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 <termios.h>
|
# include <termios.h>
|
||||||
# include "libft.h"
|
# include "libft.h"
|
||||||
|
|
||||||
|
# define TYPE_BUILTIN
|
||||||
|
|
||||||
typedef struct s_job t_job;
|
typedef struct s_job t_job;
|
||||||
typedef struct s_jobc t_jobc;
|
typedef struct s_jobc t_jobc;
|
||||||
|
|
||||||
|
|
@ -24,15 +26,20 @@ struct s_job
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
int fdin;
|
||||||
|
int fdout;
|
||||||
char *command;
|
char *command;
|
||||||
|
t_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct s_jobc
|
struct s_jobc
|
||||||
{
|
{
|
||||||
t_list *list;
|
t_list *first_job;
|
||||||
pid_t shell_pgid;
|
pid_t shell_pgid;
|
||||||
int current_id;
|
int current_id;
|
||||||
int rank[2];
|
int rank[2];
|
||||||
|
t_job job;
|
||||||
|
t_process process;
|
||||||
struct termios shell_tmodes;
|
struct termios shell_tmodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:07:44 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 17:28:14 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;
|
t_astnode *node;
|
||||||
|
|
||||||
node = (*ast)->item;
|
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);
|
ft_cmd_process(node->data.sstr);
|
||||||
btree_delone(ast, &ast_free);
|
btree_delone(ast, &ast_free);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 17:27:08 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;
|
t_astnode *node;
|
||||||
int fd;
|
int fd;
|
||||||
|
t_data *data;
|
||||||
|
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
fd = open(node->data.redir.word.word, O_RDONLY);
|
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);
|
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);
|
btree_delone(ast, &ast_free);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 21:13:23 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();
|
data = data_singleton();
|
||||||
pipe(fds);
|
pipe(fds);
|
||||||
DG("pipe %i->%i", fds[PIPE_WRITE], fds[PIPE_READ]);
|
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);
|
ft_exec(&(*ast)->left);
|
||||||
if (data->exec.fdout != STDOUT)
|
if (data->jobc.process.fdout != STDOUT)
|
||||||
close(data->exec.fdout);
|
close(data->exec.fdout);
|
||||||
data->exec.fdout = STDOUT;
|
data->jobc.process.fdout = STDOUT;
|
||||||
data->exec.fdin = fds[PIPE_READ];
|
data->jobc.process.fdin = fds[PIPE_READ];
|
||||||
ft_exec(&(*ast)->right);
|
ft_exec(&(*ast)->right);
|
||||||
close(fds[PIPE_WRITE]);
|
close(fds[PIPE_WRITE]);
|
||||||
close(fds[PIPE_READ]);
|
close(fds[PIPE_READ]);
|
||||||
data->exec.fdin = STDIN;
|
data->jobc.process.fdin = STDIN;
|
||||||
data->exec.fdout = STDOUT;
|
data->jobc.process.fdout = STDOUT;
|
||||||
btree_delone(ast, &ast_free);
|
btree_delone(ast, &ast_free);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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: 2016/12/12 17:54:45 by jhalford ### ########.fr */
|
/* Updated: 2016/12/13 12:13:24 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 21:13:18 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 16:51:54 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* data_singleton.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/12/13 11:19:51 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/12/13 11:52:47 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
t_data *data_singleton()
|
t_data *data_singleton()
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/06 18:40:58 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue