fixed leaks and some redirection errors
This commit is contained in:
@ -6,18 +6,21 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/22 17:02:13 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/22 19:12:50 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void redirect_input(t_msh *msh, int i)
|
||||
void redirect_input(t_msh *msh, int i, char **cmd_args)
|
||||
{
|
||||
if (msh->in_type != PIPE)
|
||||
{
|
||||
if (dup2(msh->in_fd, 0) < 0)
|
||||
{
|
||||
free(cmd_args);
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
close(msh->in_fd);
|
||||
}
|
||||
else
|
||||
@ -25,6 +28,7 @@ void redirect_input(t_msh *msh, int i)
|
||||
if (dup2(msh->fds[i - 1][0], 0) < 0)
|
||||
{
|
||||
perror("dup2"); //debug
|
||||
free(cmd_args);
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user