This commit is contained in:
2024-04-25 19:20:46 +02:00
parent 1366c49e99
commit 36f7bfd64d
2 changed files with 16 additions and 26 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */ /* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
/* Updated: 2024/04/25 18:21:20 by tomoron ### ########.fr */ /* Updated: 2024/04/25 19:20:22 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -72,16 +72,17 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count)
void exec_command(t_msh *msh, int i, int cmd_count) void exec_command(t_msh *msh, int i, int cmd_count)
{ {
if(msh->in_fd == -1 || msh->out_fd == -1) if(msh->out_fd != -1 || msh->in_fd != -1)
return ; {
msh->fds[i] = ft_calloc(2, sizeof(int *));
if (!msh->fds[i])
ft_exit(msh, 1);
if (msh->tokens && !cmd_is_builtin(msh, msh->tokens->value))
get_cmd_path(msh);
if ((msh->tokens && msh->tokens->value) || is_parenthesis(msh->cmds))
exec(msh, get_cmd_args(msh), i, cmd_count);
}
g_return_code = 0; g_return_code = 0;
msh->fds[i] = ft_calloc(2, sizeof(int *));
if (!msh->fds[i])
ft_exit(msh, 1);
if (msh->tokens && !cmd_is_builtin(msh, msh->tokens->value))
get_cmd_path(msh);
if ((msh->tokens && msh->tokens->value) || is_parenthesis(msh->cmds))
exec(msh, get_cmd_args(msh), i, cmd_count);
remove_command_from_msh(msh); remove_command_from_msh(msh);
} }
@ -134,7 +135,7 @@ void exec_commands(t_msh *msh)
if (!msh->pids || !msh->fds) if (!msh->pids || !msh->fds)
ft_exit(msh, 1); ft_exit(msh, 1);
i = -1; i = -1;
while (++i < cmd_count) while (++i < cmd_count && msh->in_fd >= 0 && msh->out_fd >= 0)
{ {
get_redirections(msh, msh->cmds); get_redirections(msh, msh->cmds);
exec_command(msh, i, cmd_count); exec_command(msh, i, cmd_count);

View File

@ -1,25 +1,14 @@
exit with positive and negative 18/19 digits
check error codes
Export multiple variables
./tester os_specific
Cat makefile | (echo yes && rev) leaks
echo yes && echo yes && cat dhdgdgjsk || echo a leaks
Open file descriptor with cat << eof | ls open fd and infinte loop
Cat makefile | (echo yes && rev) leaks
echo yes && echo yes && car dhdgdgjsk || echo no leaks
echo abc && echo def | cat | rev && echo yes echo abc && echo def | cat | rev && echo yes
(), ((())), (()) (), ((())), (())
export leaks export leaks AAAAAAAAAAAAAAAAAAAAAA
fix broken tests from tester
To test: To test:
Open file descriptor with cat << eof | ls open fd and infinte loop
ctrl backslash in middle of line
ctrl c on character we are ln with cursor, not end of line
test signals test signals
test and verify all malocs test and verify all malocs