it's really broken
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/04/13 13:28:48 by babonnet ### ########.fr */
|
||||
/* Updated: 2024/04/13 16:22:58 by babonnet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -68,16 +68,16 @@ void exec_command_bonus(t_msh *msh, char *cmd_str)
|
||||
int exec(t_msh *msh, char **cmd_args, int i, int cmd_count)
|
||||
{
|
||||
pid_t pid;
|
||||
int fds[2];
|
||||
|
||||
if (i != cmd_count - 1)
|
||||
{
|
||||
printf("pipe\n");
|
||||
if (pipe(fds) == -1)
|
||||
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]);
|
||||
}
|
||||
pid = fork();
|
||||
if (pid == -1)
|
||||
@ -160,6 +160,8 @@ void exec_commands(t_msh *msh)
|
||||
i = 0;
|
||||
while (i < cmd_count)
|
||||
{
|
||||
if (i != 0)
|
||||
get_redirections(msh, msh->cmds);
|
||||
exec_command(msh, i, cmd_count);
|
||||
free(msh->fds[i]);
|
||||
i++;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/13 13:42:07 by babonnet ### ########.fr */
|
||||
/* Updated: 2024/04/13 15:58:27 by babonnet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,13 +16,15 @@ void redirect_input(t_msh *msh, int i)
|
||||
{
|
||||
if (msh->in_type != PIPE)
|
||||
{
|
||||
ft_printf_fd(2, "redirecting input\n");
|
||||
if (dup2(msh->in_fd, 0) < 0)
|
||||
ft_exit(msh, 1);
|
||||
close(msh->in_fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_printf_fd(2, "%d: 0 -> %d\n", i, msh->fds[i - 1][0]);
|
||||
ft_printf_fd(2, "redirecting pipe input\n");
|
||||
ft_printf_fd(2, "input of cmd %d: 0 -> %d\n", i, msh->fds[i - 1][0]);
|
||||
if (dup2(msh->fds[i - 1][0], 0) < 0)
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/13 13:42:29 by babonnet ### ########.fr */
|
||||
/* Updated: 2024/04/13 21:25:23 by babonnet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,12 +16,14 @@ void redirect_output(t_msh *msh, int i)
|
||||
{
|
||||
if (msh->out_type != PIPE)
|
||||
{
|
||||
ft_printf_fd(2, "redirecting output\n");
|
||||
if (dup2(msh->out_fd, 1) < 0)
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_printf_fd(2, "%d: 1 -> %d\n", i, msh->fds[i - 1][1]);
|
||||
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]);
|
||||
if (dup2(msh->fds[i][1], 1) < 0)
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/13 13:39:31 by babonnet ### ########.fr */
|
||||
/* Updated: 2024/04/13 15:39:50 by babonnet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
Reference in New Issue
Block a user