didnt do much
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
/* 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->tokens = parse_command(cmds->value, msh->env);
|
||||||
msh->cmds = cmds;
|
msh->cmds = cmds;
|
||||||
get_redirections(msh, cmds);
|
get_redirections(msh, cmds);
|
||||||
print_msh_struct(msh); // debug
|
//print_msh_struct(msh); // debug
|
||||||
print_parsed_token(msh->tokens); // debug
|
//print_parsed_token(msh->tokens); // debug
|
||||||
exec_commands(msh);
|
exec_commands(msh);
|
||||||
msh->in_fd = 0;
|
msh->in_fd = 0;
|
||||||
msh->out_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)
|
if (i != cmd_count - 1)
|
||||||
{
|
{
|
||||||
printf("pipe\n");
|
|
||||||
if (pipe(msh->fds[i]) == -1)
|
if (pipe(msh->fds[i]) == -1)
|
||||||
{
|
{
|
||||||
perror("minishell: pipe");
|
perror("minishell: pipe");
|
||||||
ft_exit(msh, 1);
|
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();
|
pid = fork();
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
@ -162,6 +161,7 @@ void exec_commands(t_msh *msh)
|
|||||||
{
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
get_redirections(msh, msh->cmds);
|
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);
|
exec_command(msh, i, cmd_count);
|
||||||
free(msh->fds[i]);
|
free(msh->fds[i]);
|
||||||
i++;
|
i++;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 18:15:27 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 19:10:52 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 "minishell.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void redirect_output(t_msh *msh, int i)
|
void redirect_output(t_msh *msh, int i)
|
||||||
{
|
{
|
||||||
@ -22,10 +23,19 @@ void redirect_output(t_msh *msh, int i)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ft_printf_fd(0, "redirecting pipe output\n");
|
ft_printf_fd(2, "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, "%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)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 18:17:25 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
|
if (msh->out_type == PIPE || msh->out_type == RED_O
|
||||||
|| msh->out_type == RED_O_APP)
|
|| msh->out_type == RED_O_APP)
|
||||||
redirect_output(msh, i);
|
redirect_output(msh, i);
|
||||||
|
ft_printf_fd(2, "closing fds\n");
|
||||||
close_pipe_fds(msh, i);
|
close_pipe_fds(msh, i);
|
||||||
execute_command(msh, cmd_args);
|
execute_command(msh, cmd_args);
|
||||||
close(0);
|
close(0);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */
|
/* 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;
|
struct termios t_p;
|
||||||
|
|
||||||
ft_printf("echoctl value : %d\n",value);
|
//ft_printf("echoctl value : %d\n",value);
|
||||||
if (tcgetattr(1, &t_p))
|
if (tcgetattr(1, &t_p))
|
||||||
{
|
{
|
||||||
ft_printf_fd(2, "minishell: an error occured while getting the local fl\
|
ft_printf_fd(2, "minishell: an error occured while getting the local fl\
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/05 18:19:26 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)
|
void ft_exit(t_msh *msh, int exit_code)
|
||||||
{
|
{
|
||||||
|
ft_printf("exiting");
|
||||||
free_msh(msh);
|
free_msh(msh);
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user