diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index 8f53371..1fc8e05 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/13 16:22:58 by babonnet ### ########.fr */ +/* Updated: 2024/04/14 11:41:29 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,8 +53,8 @@ void exec_command_bonus(t_msh *msh, char *cmd_str) msh->tokens = parse_command(cmds->value, msh->env); msh->cmds = cmds; get_redirections(msh, cmds); - print_msh_struct(msh); // debug - print_parsed_token(msh->tokens); // debug + //print_msh_struct(msh); // debug + //print_parsed_token(msh->tokens); // debug exec_commands(msh); msh->in_fd = 0; msh->out_fd = 0; @@ -71,13 +71,12 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count) if (i != cmd_count - 1) { - printf("pipe\n"); if (pipe(msh->fds[i]) == -1) { perror("minishell: pipe"); ft_exit(msh, 1); } - ft_printf_fd(2, "msh->fds[%d][0]: %d, msh->fds[%d][1]: %d\n", i, msh->fds[i][0], i, msh->fds[i][1]); + ft_printf_fd(2, "pipe: msh->fds[%d][0]: %d, msh->fds[%d][1]: %d\n", i, msh->fds[i][0], i, msh->fds[i][1]); } pid = fork(); if (pid == -1) @@ -162,6 +161,7 @@ void exec_commands(t_msh *msh) { if (i != 0) get_redirections(msh, msh->cmds); + ft_printf_fd(2, "command: %s, in_type: %d, out_type: %d\n", msh->cmds->value, msh->in_type, msh->out_type); exec_command(msh, i, cmd_count); free(msh->fds[i]); i++; diff --git a/srcs/input_redirections.c b/srcs/input_redirections.c index 7b79faa..222c85e 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/13 15:58:27 by babonnet ### ########.fr */ +/* Updated: 2024/04/14 10:41:33 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/srcs/output_redirections.c b/srcs/output_redirections.c index 6b88955..9b7c955 100755 --- a/srcs/output_redirections.c +++ b/srcs/output_redirections.c @@ -6,11 +6,12 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */ -/* Updated: 2024/04/13 21:25:23 by babonnet ### ########.fr */ +/* Updated: 2024/04/15 12:36:18 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +#include void redirect_output(t_msh *msh, int i) { @@ -22,10 +23,19 @@ void redirect_output(t_msh *msh, int i) } else { - ft_printf_fd(0, "redirecting pipe output\n"); - ft_printf_fd(0, "output of cmd %d: 1 -> %d\n", i, msh->fds[i - 1][1]); + ft_printf_fd(2, "redirecting pipe output\n"); + ft_printf_fd(2, "%p\n", msh->fds[i]); + //ft_printf_fd(2, "output of cmd %d: 1 -> %d\n", i, msh->fds[i - 1][1]); + ft_printf_fd(2, "yes\n"); + //sleep(1); if (dup2(msh->fds[i][1], 1) < 0) - ft_exit(msh, 1); + { + perror("dup2"); + ft_printf_fd(2, "exiting\n"); + //ft_exit(msh, 1); + } + ft_printf_fd(2,"help pls\n"); + fflush(stdout); // Flush stdout } } diff --git a/srcs/pipe.c b/srcs/pipe.c index 32494b4..755b11a 100755 --- a/srcs/pipe.c +++ b/srcs/pipe.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */ -/* Updated: 2024/04/13 15:39:50 by babonnet ### ########.fr */ +/* Updated: 2024/04/14 11:34:47 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,6 +56,7 @@ void child(t_msh *msh, char **cmd_args, int i) if (msh->out_type == PIPE || msh->out_type == RED_O || msh->out_type == RED_O_APP) redirect_output(msh, i); + ft_printf_fd(2, "closing fds\n"); close_pipe_fds(msh, i); execute_command(msh, cmd_args); close(0); diff --git a/srcs/signal_handler.c b/srcs/signal_handler.c index 8e766b9..a976d86 100755 --- a/srcs/signal_handler.c +++ b/srcs/signal_handler.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */ -/* Updated: 2024/04/03 19:23:33 by tomoron ### ########.fr */ +/* Updated: 2024/04/14 11:41:06 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,7 +57,7 @@ int set_echoctl(int value) { struct termios t_p; - ft_printf("echoctl value : %d\n",value); + //ft_printf("echoctl value : %d\n",value); if (tcgetattr(1, &t_p)) { ft_printf_fd(2, "minishell: an error occured while getting the local fl\ diff --git a/srcs/utils.c b/srcs/utils.c index e80d1a3..0d87989 100755 --- a/srcs/utils.c +++ b/srcs/utils.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */ -/* Updated: 2024/04/03 15:46:38 by tomoron ### ########.fr */ +/* Updated: 2024/04/14 11:29:02 by marde-vr ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,7 @@ void free_msh(t_msh *msh) void ft_exit(t_msh *msh, int exit_code) { + ft_printf("exiting"); free_msh(msh); exit(exit_code); }