summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/e_builtins.c2
-rw-r--r--src/e_externs.c2
-rw-r--r--src/m_loop.c1
-rw-r--r--src/s_struct.h21
-rw-r--r--src/u_utils.c6
-rw-r--r--src/u_utils.h2
6 files changed, 18 insertions, 16 deletions
diff --git a/src/e_builtins.c b/src/e_builtins.c
index b94c328..666cf11 100644
--- a/src/e_builtins.c
+++ b/src/e_builtins.c
@@ -49,7 +49,7 @@ static void
e_export_env_fork(ptr, msh);
dup_redirs(ptr, msh);
ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh);
- u_eof_stdin();
+ u_eof_fd(msh->fd);
s_line_clear(&msh->curr);
s_destroy(msh);
exit(ret);
diff --git a/src/e_externs.c b/src/e_externs.c
index 4cc63e1..253d758 100644
--- a/src/e_externs.c
+++ b/src/e_externs.c
@@ -36,7 +36,7 @@ static void
{
f_exec(fullpath);
ft_memdel((void*)&fullpath);
- u_eof_stdin();
+ u_eof_fd(msh->fd);
s_line_clear(&msh->curr);
s_destroy(msh);
exit(errno);
diff --git a/src/m_loop.c b/src/m_loop.c
index e174f30..c25188e 100644
--- a/src/m_loop.c
+++ b/src/m_loop.c
@@ -36,6 +36,7 @@ uint8_t
char *line;
int8_t gnl;
+ msh->fd = fd;
gnl = 1;
while (gnl > 0)
{
diff --git a/src/s_struct.h b/src/s_struct.h
index 54d3af3..3f9e84f 100644
--- a/src/s_struct.h
+++ b/src/s_struct.h
@@ -28,19 +28,19 @@
typedef struct s_lvars
{
+ struct s_lvars *next;
char *name;
char *val;
- struct s_lvars *next;
} t_lvars;
typedef struct s_com
{
- char *bin;
char **argv;
- int8_t redir;
- int32_t rdrfd;
- char *rdrpath;
char **env_fork;
+ char *rdrpath;
+ char *bin;
+ int32_t rdrfd;
+ int8_t redir;
} t_com;
struct s_lpipes
@@ -59,25 +59,26 @@ struct s_lpipes
typedef struct s_line
{
- uint8_t nextif;
struct s_com *com;
struct s_lpipes *pipes;
struct s_line *next;
+ uint8_t nextif;
} t_line;
typedef struct s_msh
{
+ struct s_line *curr;
+ struct s_lvars *vars;
char **envp;
+ char **bu_ref;
char ps[4][1024];
- uint8_t ret;
char *shname;
- char **bu_ref;
char *cwd;
+ int32_t fd;
char env_fork_tmp[128][1024];
char sqb_ref[FT_ID_SQB_COUNT][4];
uint8_t (*bu_ptr[FT_BUILTINS_COUNT])(char **, struct s_msh*);
- struct s_line *curr;
- struct s_lvars *vars;
+ uint8_t ret;
} t_msh;
#endif
diff --git a/src/u_utils.c b/src/u_utils.c
index f50d861..ad44e82 100644
--- a/src/u_utils.c
+++ b/src/u_utils.c
@@ -19,12 +19,12 @@
#include "s_struct.h"
void
-u_eof_stdin(void)
+ u_eof_fd(int32_t fd)
{
char *line;
- close(STDIN_FILENO);
- get_next_line(STDIN_FILENO, &line);
+ close(fd);
+ get_next_line(fd, &line);
ft_memdel((void*)&line);
}
diff --git a/src/u_utils.h b/src/u_utils.h
index 9943f41..22b63ff 100644
--- a/src/u_utils.h
+++ b/src/u_utils.h
@@ -17,7 +17,7 @@
#include "s_struct.h"
-void u_eof_stdin(void);
+void u_eof_fd(int32_t fd);
uint64_t u_builtins_get_argc(const char *args[]);
char **u_get_env_var_names(t_msh *msh);