AAAAAAAAAAA
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/06 14:25:19 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/06 15:18:28 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -80,11 +80,9 @@ void exec_command(t_msh *msh, int i, int cmd_count)
|
||||
msh->fds[i] = ft_calloc(2, sizeof(int *));
|
||||
if (!msh->fds[i])
|
||||
ft_exit(msh, 1);
|
||||
if (msh->tokens && !cmd_is_builtin(msh, msh->tokens->value)
|
||||
&& msh->in_fd != -1)
|
||||
if (msh->tokens && !cmd_is_builtin(msh, msh->tokens->value) && msh->in_fd != -1)
|
||||
get_cmd_path(msh);
|
||||
if (((msh->tokens && msh->tokens->value) || is_parenthesis(msh->cmds))
|
||||
&& msh->in_fd != -1)
|
||||
if (((msh->tokens && msh->tokens->value) || is_parenthesis(msh->cmds)) && msh->in_fd != -1)
|
||||
exec(msh, get_cmd_args(msh), i, cmd_count);
|
||||
else
|
||||
{
|
||||
@ -92,6 +90,8 @@ void exec_command(t_msh *msh, int i, int cmd_count)
|
||||
close(msh->in_fd);
|
||||
if (msh->out_fd > 2)
|
||||
close(msh->out_fd);
|
||||
if(!g_return_code)
|
||||
g_return_code = 1;
|
||||
}
|
||||
}
|
||||
remove_command_from_msh(msh);
|
||||
@ -106,7 +106,7 @@ void end_execution(t_msh *msh, int cmd_count)
|
||||
status = 0;
|
||||
while (i < cmd_count)
|
||||
waitpid(msh->pids[i++], &status, 0);
|
||||
close_all_pipes(msh, cmd_count, i);
|
||||
close_all_pipes(msh);
|
||||
if (!g_return_code && WIFEXITED(status))
|
||||
g_return_code = WEXITSTATUS(status);
|
||||
if (WIFSIGNALED(status))
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/26 13:15:24 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/05/06 15:09:44 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -44,6 +44,7 @@ void here_doc_child(t_msh *msh, char *eof)
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
get_here_doc_input(msh, eof);
|
||||
close(msh->in_fd);
|
||||
close_all_pipes(msh);
|
||||
ft_exit(msh, 0);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/05/06 14:14:21 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/06 14:43:48 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/06 14:27:14 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/06 15:17:14 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -98,7 +98,6 @@ void redirect_output(t_msh *msh, int i, char **cmd_args);
|
||||
void redirect_input(t_msh *msh, int i, char **cmd_args);
|
||||
void print_syntax_error_bonus(t_cmd *cmd, t_cmd *cmds);
|
||||
int filename_corresponds(char *wildcard, char *value);
|
||||
void close_all_pipes(t_msh *msh, int cmd_count, int i);
|
||||
t_token *parse_cmds_to_token(t_cmd *command, t_env *env);
|
||||
int ft_export(t_msh *msh, t_token *cmd, t_env *env);
|
||||
void print_env_declare(t_msh *msh, t_env *env_orig);
|
||||
@ -139,12 +138,15 @@ int get_normal_cmd_len(char *cmd);
|
||||
t_cmd *get_next_command(t_cmd *cmd);
|
||||
int get_args_count(t_token *cmds);
|
||||
char **env_to_char_tab(t_env *env);
|
||||
int get_token_len(char *command);
|
||||
int first_is_in_type(t_cmd *cmd);
|
||||
void print_msh_struct(t_msh *msh);
|
||||
int get_next_arg_len(char *cmd);
|
||||
int check_str_syntax(char *cmd);
|
||||
void close_all_pipes(t_msh *msh);
|
||||
int is_operand_type(t_cmd *cmd);
|
||||
int contains_newline(char *str);
|
||||
t_token *free_token(t_token *token);
|
||||
int get_cmd_count(t_cmd *cmds);
|
||||
int check_var_name(char *name);
|
||||
char **get_cmd_args(t_msh *msh);
|
||||
@ -153,6 +155,7 @@ int is_parenthesis(t_cmd *cmd);
|
||||
int is_output_type(t_cmd *cmd);
|
||||
int is_parenthesis(t_cmd *cmd);
|
||||
void print_signaled(int status);
|
||||
void exec_commands(t_msh *msh);
|
||||
int is_input_type(t_cmd *cmd);
|
||||
char *remove_path(char *token);
|
||||
t_cmd *parsing_bonus(char *cmd);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/19 14:09:44 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/06 10:28:56 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/06 14:43:45 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/30 14:03:28 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/05/06 15:17:37 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -74,10 +74,12 @@ int file_access(t_msh *msh, int *found)
|
||||
return (1);
|
||||
}
|
||||
|
||||
void close_all_pipes(t_msh *msh, int cmd_count, int i)
|
||||
void close_all_pipes(t_msh *msh)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < cmd_count)
|
||||
while (msh->fds[i])
|
||||
{
|
||||
close_pipe_fds(msh, i);
|
||||
i++;
|
||||
|
Reference in New Issue
Block a user