Merge branch 'master' into sadjigui
This commit is contained in:
commit
63aeb7843e
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/09 22:33:49 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/14 10:30:52 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/15 00:20:25 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -33,18 +33,18 @@
|
||||
// Describes a simple command and arguments
|
||||
typedef struct s_simple {
|
||||
struct s_command *big_cmd;
|
||||
int fd[2];
|
||||
int pipe[2];
|
||||
int last;
|
||||
int last_pipe[2];
|
||||
int child;
|
||||
int nb_args;
|
||||
char *infile;
|
||||
int in_type;
|
||||
int out_type;
|
||||
char *outfile;
|
||||
char **args;
|
||||
char *cmd;
|
||||
int fd[2];
|
||||
int pipe[2];
|
||||
int last;
|
||||
int last_pipe[2];
|
||||
int child;
|
||||
int nb_args;
|
||||
char *infile;
|
||||
int in_type;
|
||||
int out_type;
|
||||
char *outfile;
|
||||
char **args;
|
||||
char *cmd;
|
||||
} t_s_cmd;
|
||||
|
||||
// Describes a complete command with the multiple pipes if any
|
||||
@ -86,6 +86,7 @@ char **ft_split_with_quote(char const *s, char c);
|
||||
|
||||
//signals
|
||||
void crtl_c(int num);
|
||||
void sig_heredoc(int num);
|
||||
|
||||
//redirection.c set redirection and input good
|
||||
char *set_redirection(t_s_cmd *cmd, char *line, int index);
|
||||
@ -95,7 +96,7 @@ char next_space(char *str, int i);
|
||||
int parse_quote(t_cmd *cmd);
|
||||
char *get_str(char *str, int start, int end);
|
||||
char *cut_str(char *str, int start, int end);
|
||||
int double_size(char **tab);
|
||||
int double_size(char **tab);
|
||||
void print_double_fd(char **tab, int fd);
|
||||
void free_double(char **tab);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/06 13:27:11 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/14 10:35:08 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/15 00:13:24 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -53,7 +53,7 @@ void print_prompt(char **path)
|
||||
{
|
||||
char *input;
|
||||
t_cmd *cmd;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
input = 0;
|
||||
i = 0;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/04/02 18:51:31 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/14 11:27:29 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/15 01:10:14 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -47,19 +47,23 @@ int wait_exit(t_cmd *cmd)
|
||||
{
|
||||
close(cmd->s_cmds[i]->fd[0]);
|
||||
close(cmd->s_cmds[i]->fd[1]);
|
||||
}
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
if (!cmd->err_var)
|
||||
cmd->err_var = WEXITSTATUS(status);
|
||||
//printf("return normally cmd = -%s-\n", cmd->s_cmds[i]->cmd);
|
||||
//if (!cmd->err_var)
|
||||
cmd->err_var = WEXITSTATUS(status);
|
||||
//printf("err_var= %d\n", cmd->err_var);
|
||||
//printf("code= %d\n", cmd->err_var);
|
||||
}
|
||||
else if (WIFSIGNALED(status))
|
||||
{
|
||||
cmd->err_var = WTERMSIG(status);
|
||||
//printf("return by signal cmd = -%s-\n", cmd->s_cmds[i]->cmd);
|
||||
if (WTERMSIG(status) != 13)
|
||||
cmd->err_var = WTERMSIG(status);
|
||||
//if (cmd->err_var == 2)
|
||||
ft_putstr_fd("\b\b\b\b\b", 1);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -120,6 +124,7 @@ void execute(t_cmd *cmd, char **env)
|
||||
fdin=dup(tmpin);
|
||||
while(cmd->current_s_cmd)
|
||||
{
|
||||
cmd->current_s_cmd->child = 0;
|
||||
fdout = 0;
|
||||
if (i > 0 && cmd->current_s_cmd->infile)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/09 15:18:58 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/14 11:28:30 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/15 00:13:27 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user