From 7b5df4fa3a6521b1a1eb285693fef7a17d75710f Mon Sep 17 00:00:00 2001 From: mdev9 Date: Fri, 26 Apr 2024 13:27:27 +0200 Subject: [PATCH] fixed some minor issues --- srcs/exec_bonus.c | 8 ++++---- srcs/here_doc.c | 4 ++-- srcs/input_redirections.c | 4 ++-- todo_list | 6 ------ 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index ba77342..c3b7113 100755 --- a/srcs/exec_bonus.c +++ b/srcs/exec_bonus.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */ -/* Updated: 2024/04/26 11:08:13 by tomoron ### ########.fr */ +/* Updated: 2024/04/26 13:14:42 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -73,9 +73,9 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count) void exec_command(t_msh *msh, int i, int cmd_count) { get_redirections(msh, msh->cmds); - g_return_code = 0; - if (msh->out_fd != -1 && msh->in_fd != -1) + if (msh->in_fd != -2) { + g_return_code = 0; msh->fds[i] = ft_calloc(2, sizeof(int *)); if (!msh->fds[i]) ft_exit(msh, 1); @@ -135,7 +135,7 @@ void exec_commands(t_msh *msh) if (!msh->pids || !msh->fds) ft_exit(msh, 1); i = -1; - while (++i < cmd_count && msh->in_fd >= 0 && msh->out_fd >= 0) + while (++i < cmd_count && msh->in_fd != -2) exec_command(msh, i, cmd_count); free_token(msh->tokens); end_execution(msh, cmd_count); diff --git a/srcs/here_doc.c b/srcs/here_doc.c index 8b9daa4..1b2e036 100755 --- a/srcs/here_doc.c +++ b/srcs/here_doc.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */ -/* Updated: 2024/04/26 11:06:25 by tomoron ### ########.fr */ +/* Updated: 2024/04/26 13:15:24 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -61,7 +61,7 @@ void here_doc_signal(t_msh *msh, int child_pid, char *here_doc_file) if (WIFEXITED(status) && WEXITSTATUS(status)) { unlink(here_doc_file); - msh->in_fd = -1; + msh->in_fd = -2; g_return_code = 130; return ; } diff --git a/srcs/input_redirections.c b/srcs/input_redirections.c index 25ed912..d6b590e 100755 --- a/srcs/input_redirections.c +++ b/srcs/input_redirections.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */ -/* Updated: 2024/04/25 18:39:48 by tomoron ### ########.fr */ +/* Updated: 2024/04/26 13:25:15 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,7 +57,7 @@ int open_input_file(t_msh *msh, t_cmd **cur_token) ambiguous_redirect((*cur_token)->value, msh); if (!filename->next) msh->in_fd = open(filename->value, O_RDONLY); - if (msh->in_fd == -1) + if (msh->in_fd == -1 && !filename->next) { ft_printf_fd(2, "minishell: %s: ", filename->value); perror(""); diff --git a/todo_list b/todo_list index edc7a20..6ae8f09 100644 --- a/todo_list +++ b/todo_list @@ -1,14 +1,8 @@ - Cat makefile | (echo yes && rev) leaks -echo yes && echo yes && cat dhdgdgjsk || echo a leaks -echo abc && echo def | cat | rev && echo yes (), ((())), (()) -export leaks AAAAAAAAAAAAAAAAAAAAAA - To test: -Open file descriptor with cat << eof | ls open fd and infinte loop test signals test and verify all malocs