fixed some leaks and error codes

This commit is contained in:
mdev9
2024-02-28 18:55:03 +01:00
parent 02d4d7d782
commit 08debcb6f2
3 changed files with 20 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
/* Updated: 2024/02/28 12:47:01 by marde-vr ### ########.fr */
/* Updated: 2024/02/28 18:53:41 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
@ -201,12 +201,26 @@ void pipe_child(t_msh *msh, char **cmd_args, int i)
|| !ft_strcmp(msh->cmds->token, "alias")
|| !ft_strcmp(msh->cmds->token, "unalias")
|| !ft_strcmp(msh->cmds->token, "exit") || exec_builtin(msh)))
{
while(i >= 0)
{
free(msh->fds[i]);
i--;
}
free(cmd_args);
ft_exit(msh, 1);
}
if (msh->cmds->token)
execve(msh->cmds->token, cmd_args, env_to_char_tab(msh->env));
close(0);
close(1);
close(2);
while(i >= 0)
{
free(msh->fds[i]);
i--;
}
free(cmd_args);
ft_exit(msh, 1);
}
@ -383,7 +397,7 @@ void get_out_type(t_msh *msh)
if (msh->out_fd == -1)
{
perror("open");
ft_exit(msh, 2);
ft_exit(msh, 1);
}
}
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/26 20:20:31 by marde-vr #+# #+# */
/* Updated: 2024/02/27 19:23:08 by marde-vr ### ########.fr */
/* Updated: 2024/02/28 17:39:18 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
@ -93,7 +93,7 @@ void handle_here_doc(t_msh *msh, char *eof)
if (msh->in_fd == -1)
{
perror("open");
ft_exit(msh, 2);
ft_exit(msh, 1);
}
eof = ft_strjoin_free(eof, "\n", 1);
if (!eof)
@ -104,6 +104,6 @@ void handle_here_doc(t_msh *msh, char *eof)
if (msh->in_fd == -1)
{
perror("open");
ft_exit(msh, 2);
ft_exit(msh, 1);
}
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/09 15:26:01 by tomoron #+# #+# */
/* Updated: 2024/02/21 12:57:40 by marde-vr ### ########.fr */
/* Updated: 2024/02/28 18:48:27 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"