/* By: ljiriste <ljiriste@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/21 08:57:54 by ljiriste #+# #+# */
-/* Updated: 2024/08/01 15:51:03 by ljiriste ### ########.fr */
+/* Updated: 2024/08/01 16:07:38 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
{
redir = ft_vec_caccess(redirections, i);
dup2(redir->from_to_fds[1], redir->from_to_fds[0]);
+ close(redir->from_to_fds[1]);
++i;
}
return (0);
return (0);
}
+void close_redirection(void *v_redir)
+{
+ t_redirection *redir;
+
+ redir = v_redir;
+ close(redir->from_to_fds[1]);
+ return ;
+}
+
int ex_simple_command(t_parse_tree_node *simple_command, t_execution_env *env)
{
t_vec redirections;
fields = expand(simple_command, env);
if (!fields || res)
{
- ft_vec_free(&redirections, NULL);
+ ft_vec_free(&redirections, close_redirection);
ft_vec_free(&assignments, free);
return (1);
}
if (!*fields)
{
assignments_to_env(&assignments, env);
- ft_vec_free(&redirections, NULL);
+ ft_vec_free(&redirections, close_redirection);
ft_vec_free(&assignments, NULL);
free_split(fields);
return (0);
}
res = ex_fields(fields, &assignments, &redirections, env);
- ft_vec_free(&redirections, NULL);
+ ft_vec_free(&redirections, close_redirection);
ft_vec_free(&assignments, free);
free_split(fields);
return (res);