protected opens
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/02/07 14:12:49 by tomoron #+# #+# */
|
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/02/27 18:44:14 by marde-vr ### ########.fr */
|
/* Updated: 2024/02/27 19:20:14 by marde-vr ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -110,7 +110,6 @@ 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_fd(2, "exiting");
|
|
||||||
free_msh(msh);
|
free_msh(msh);
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
@ -379,7 +378,10 @@ void get_out_type(t_msh *msh)
|
|||||||
msh->out_fd = open(cur_cmd->next->token,
|
msh->out_fd = open(cur_cmd->next->token,
|
||||||
O_CREAT | O_RDWR | O_APPEND, 0644);
|
O_CREAT | O_RDWR | O_APPEND, 0644);
|
||||||
if (msh->out_fd == -1)
|
if (msh->out_fd == -1)
|
||||||
|
{
|
||||||
|
perror("open");
|
||||||
ft_exit(msh, 2);
|
ft_exit(msh, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/26 20:20:31 by marde-vr #+# #+# */
|
/* Created: 2024/02/26 20:20:31 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/02/26 20:40:00 by marde-vr ### ########.fr */
|
/* Updated: 2024/02/27 19:23:08 by marde-vr ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -91,11 +91,19 @@ void handle_here_doc(t_msh *msh, char *eof)
|
|||||||
here_doc_file = get_tmp_file_name(msh);
|
here_doc_file = get_tmp_file_name(msh);
|
||||||
msh->in_fd = open(here_doc_file, O_CREAT | O_RDWR, 0644);
|
msh->in_fd = open(here_doc_file, O_CREAT | O_RDWR, 0644);
|
||||||
if (msh->in_fd == -1)
|
if (msh->in_fd == -1)
|
||||||
|
{
|
||||||
|
perror("open");
|
||||||
ft_exit(msh, 2);
|
ft_exit(msh, 2);
|
||||||
|
}
|
||||||
eof = ft_strjoin_free(eof, "\n", 1);
|
eof = ft_strjoin_free(eof, "\n", 1);
|
||||||
if (!eof)
|
if (!eof)
|
||||||
ft_exit(msh, 1);
|
ft_exit(msh, 1);
|
||||||
get_here_doc_input(msh, eof);
|
get_here_doc_input(msh, eof);
|
||||||
close(msh->in_fd);
|
close(msh->in_fd);
|
||||||
msh->in_fd = open(here_doc_file, O_RDWR, 0644);
|
msh->in_fd = open(here_doc_file, O_RDWR, 0644);
|
||||||
|
if (msh->in_fd == -1)
|
||||||
|
{
|
||||||
|
perror("open");
|
||||||
|
ft_exit(msh, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user