From 36f7bfd64d8fc7511acf257ddf4a83476d001a74 Mon Sep 17 00:00:00 2001 From: tomoron Date: Thu, 25 Apr 2024 19:20:46 +0200 Subject: [PATCH] chepa --- srcs/exec_bonus.c | 23 ++++++++++++----------- todo_list | 19 ++++--------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index aaec259..fa8f4cd 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/25 18:21:20 by tomoron ### ########.fr */ +/* Updated: 2024/04/25 19:20:22 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -72,16 +72,17 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count) void exec_command(t_msh *msh, int i, int cmd_count) { - if(msh->in_fd == -1 || msh->out_fd == -1) - return ; + if(msh->out_fd != -1 || msh->in_fd != -1) + { + 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)) + get_cmd_path(msh); + if ((msh->tokens && msh->tokens->value) || is_parenthesis(msh->cmds)) + exec(msh, get_cmd_args(msh), i, cmd_count); + } g_return_code = 0; - 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)) - get_cmd_path(msh); - if ((msh->tokens && msh->tokens->value) || is_parenthesis(msh->cmds)) - exec(msh, get_cmd_args(msh), i, cmd_count); remove_command_from_msh(msh); } @@ -134,7 +135,7 @@ void exec_commands(t_msh *msh) if (!msh->pids || !msh->fds) ft_exit(msh, 1); i = -1; - while (++i < cmd_count) + while (++i < cmd_count && msh->in_fd >= 0 && msh->out_fd >= 0) { get_redirections(msh, msh->cmds); exec_command(msh, i, cmd_count); diff --git a/todo_list b/todo_list index 51e8309..edc7a20 100644 --- a/todo_list +++ b/todo_list @@ -1,25 +1,14 @@ -exit with positive and negative 18/19 digits -check error codes -Export multiple variables -./tester os_specific - - -Open file descriptor with cat << eof | ls open fd and infinte loop -Cat makefile | (echo yes && rev) leaks -echo yes && echo yes && car dhdgdgjsk || echo no leaks +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 +export leaks AAAAAAAAAAAAAAAAAAAAAA -fix broken tests from tester To test: - - -ctrl backslash in middle of line -ctrl c on character we are ln with cursor, not end of line +Open file descriptor with cat << eof | ls open fd and infinte loop test signals test and verify all malocs