Merge branch 'main' of github.com:mdev9/minishell
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/26 11:08:13 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/26 13:14:42 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -73,9 +73,9 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count)
|
||||
void exec_command(t_msh *msh, int i, int cmd_count)
|
||||
{
|
||||
get_redirections(msh, msh->cmds);
|
||||
g_return_code = 0;
|
||||
if (msh->out_fd != -1 && msh->in_fd != -1)
|
||||
if (msh->in_fd != -2)
|
||||
{
|
||||
g_return_code = 0;
|
||||
msh->fds[i] = ft_calloc(2, sizeof(int *));
|
||||
if (!msh->fds[i])
|
||||
ft_exit(msh, 1);
|
||||
@ -135,7 +135,7 @@ void exec_commands(t_msh *msh)
|
||||
if (!msh->pids || !msh->fds)
|
||||
ft_exit(msh, 1);
|
||||
i = -1;
|
||||
while (++i < cmd_count && msh->in_fd >= 0 && msh->out_fd >= 0)
|
||||
while (++i < cmd_count && msh->in_fd != -2)
|
||||
exec_command(msh, i, cmd_count);
|
||||
free_token(msh->tokens);
|
||||
end_execution(msh, cmd_count);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/26 11:06:25 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/26 13:15:24 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -61,7 +61,7 @@ void here_doc_signal(t_msh *msh, int child_pid, char *here_doc_file)
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status))
|
||||
{
|
||||
unlink(here_doc_file);
|
||||
msh->in_fd = -1;
|
||||
msh->in_fd = -2;
|
||||
g_return_code = 130;
|
||||
return ;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/25 18:39:48 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/04/26 13:25:15 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -57,7 +57,7 @@ int open_input_file(t_msh *msh, t_cmd **cur_token)
|
||||
ambiguous_redirect((*cur_token)->value, msh);
|
||||
if (!filename->next)
|
||||
msh->in_fd = open(filename->value, O_RDONLY);
|
||||
if (msh->in_fd == -1)
|
||||
if (msh->in_fd == -1 && !filename->next)
|
||||
{
|
||||
ft_printf_fd(2, "minishell: %s: ", filename->value);
|
||||
perror("");
|
||||
|
@ -1,14 +1,8 @@
|
||||
|
||||
Cat makefile | (echo yes && rev) leaks
|
||||
echo yes && echo yes && cat dhdgdgjsk || echo a leaks
|
||||
echo abc && echo def | cat | rev && echo yes
|
||||
(), ((())), (())
|
||||
export leaks AAAAAAAAAAAAAAAAAAAAAA
|
||||
|
||||
|
||||
|
||||
To test:
|
||||
Open file descriptor with cat << eof | ls open fd and infinte loop
|
||||
|
||||
test signals
|
||||
test and verify all malocs
|
||||
|
Reference in New Issue
Block a user