fix: signal
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/29 17:32:06 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/04/05 14:12:02 by alouis-j ### ########.fr */
|
||||
/* Updated: 2023/04/05 14:53:18 by alouis-j ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -98,7 +98,7 @@ static bool ft_check_outfile_append(t_data *data, t_cmd *cmd,
|
||||
{
|
||||
if (cmd->fd_out[0] == -2)
|
||||
return (0);
|
||||
if (ft_file_is_writable(data, redirection))
|
||||
if (ft_file_is_appendable(data, redirection))
|
||||
{
|
||||
fd = open(redirection,
|
||||
O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 17:36:11 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/03/30 13:26:31 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/04/05 15:12:41 by alouis-j ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -20,14 +20,14 @@ int ft_file_is_readable(t_data *data, const char *path)
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
data->exit_code = 1;
|
||||
*data->exit_code = 1;
|
||||
ft_eprintf("minishell: %s: No such file or directory\n", path);
|
||||
return (0);
|
||||
}
|
||||
readable = read(fd, "", 0);
|
||||
if (readable == -1)
|
||||
{
|
||||
data->exit_code = 1;
|
||||
*data->exit_code = 1;
|
||||
ft_eprintf("minishell: %s: Permission denied\n", path);
|
||||
return (0);
|
||||
}
|
||||
@ -43,14 +43,14 @@ int ft_file_is_writable(t_data *data, const char *path)
|
||||
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, 0644);
|
||||
if (fd == -1)
|
||||
{
|
||||
data->exit_code = 1;
|
||||
*data->exit_code = 1;
|
||||
ft_eprintf("minishell: %s: Permission denied\n", path);
|
||||
return (0);
|
||||
}
|
||||
writeable = write(fd, "", 0);
|
||||
if (writeable == -1)
|
||||
{
|
||||
data->exit_code = 1;
|
||||
*data->exit_code = 1;
|
||||
ft_eprintf("minishell: %s: Permission denied\n", path);
|
||||
return (0);
|
||||
}
|
||||
@ -66,14 +66,14 @@ int ft_file_is_appendable(t_data *data, const char *path)
|
||||
fd = open(path, O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
if (fd == -1)
|
||||
{
|
||||
data->exit_code = 1;
|
||||
*data->exit_code = 1;
|
||||
ft_eprintf("minishell: %s: Permission denied\n", path);
|
||||
return (0);
|
||||
}
|
||||
writeable = write(fd, "", 0);
|
||||
if (writeable == -1)
|
||||
{
|
||||
data->exit_code = 1;
|
||||
*data->exit_code = 1;
|
||||
ft_eprintf("minishell: %s: Permission denied\n", path);
|
||||
return (0);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/17 15:36:26 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/04/05 14:07:10 by alouis-j ### ########.fr */
|
||||
/* Updated: 2023/04/05 14:58:01 by alouis-j ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -82,7 +82,8 @@ int ft_heredoc(t_data *data, char *stop)
|
||||
break ;
|
||||
else if (return_code == 1)
|
||||
{
|
||||
close(*ft_get_heredoc());
|
||||
if (*ft_get_heredoc() > 2)
|
||||
close(*ft_get_heredoc());
|
||||
*ft_get_heredoc() = -1;
|
||||
return (-2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user