/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/02 17:40:19 by ljiriste #+# #+# */
-/* Updated: 2024/09/01 14:43:27 by ljiriste ### ########.fr */
+/* Updated: 2024/09/05 09:25:52 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
const t_vec *redirections, t_execution_env *env);
int ex_command(t_parse_tree_node *command, t_execution_env *env);
int ex_pipeline(t_parse_tree_node *pipeline,
- t_execution_env *env, int depth);
+ t_execution_env *env, size_t depth);
int ex_program(t_parse_tree_node *program, t_execution_env *env);
char *get_word(const t_parse_tree_node *parent);
/* By: lnikolov <lnikolov@student.42prague.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/01 11:52:56 by lnikolov #+# #+# */
-/* Updated: 2024/09/01 13:43:51 by lnikolov ### ########.fr */
+/* Updated: 2024/09/05 09:26:28 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
}
static int advance_pipeline(t_parse_tree_node *pipeline,
- t_execution_env *env, int depth)
+ t_execution_env *env, size_t depth)
{
int pipe_fds[2];
int res;
|| ex_pipeline(ft_vec_access(&pipeline->children, 0), env, depth + 1);
ft_swap_int(&pipe_fds[1], &env->stdout_fd);
close(pipe_fds[1]);
- if (res == 0)
- {
+ if (env->fds_to_close.size == 2 * depth + 2)
ft_vec_forget(&env->fds_to_close, env->fds_to_close.size - 1);
+ if (env->fds_to_close.size == 2 * depth + 1)
ft_vec_forget(&env->fds_to_close, env->fds_to_close.size - 1);
- }
ft_swap_int(&pipe_fds[0], &env->stdin_fd);
res = res || ex_command(ft_vec_access(&pipeline->children, 2), env);
ft_swap_int(&pipe_fds[0], &env->stdin_fd);
return (res);
}
-int ex_pipeline(t_parse_tree_node *pipeline, t_execution_env *env, int depth)
+int ex_pipeline(t_parse_tree_node *pipeline, t_execution_env *env, size_t depth)
{
if (g_last_signal != 0)
return (0);