fix fds ouverts
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/05/03 13:10:12 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/05/06 10:24:38 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -84,6 +84,13 @@ void exec_command(t_msh *msh, int i, int cmd_count)
|
||||
get_cmd_path(msh);
|
||||
if ((msh->tokens && msh->tokens->value) || is_parenthesis(msh->cmds))
|
||||
exec(msh, get_cmd_args(msh), i, cmd_count);
|
||||
else
|
||||
{
|
||||
if (msh->in_fd > 2)
|
||||
close(msh->in_fd);
|
||||
if (msh->out_fd > 2)
|
||||
close(msh->out_fd);
|
||||
}
|
||||
}
|
||||
remove_command_from_msh(msh);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 10:46:28 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/30 14:41:48 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/05/06 10:13:22 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -50,18 +50,22 @@ int get_cmd_count(t_cmd *cmds)
|
||||
{
|
||||
int nb;
|
||||
|
||||
nb = 0;
|
||||
nb = 1;
|
||||
while (cmds && !is_operand_type(cmds))
|
||||
{
|
||||
while (cmds && (is_output_type(cmds) || is_input_type(cmds)))
|
||||
/*while (cmds && (is_output_type(cmds) || is_input_type(cmds)))
|
||||
cmds = cmds->next;
|
||||
if (is_cmd_type(cmds))
|
||||
if (cmds && is_cmd_type(cmds))
|
||||
nb++;
|
||||
while (cmds && (is_output_type(cmds) || is_input_type(cmds)
|
||||
|| is_cmd_type(cmds)))
|
||||
cmds = cmds->next;
|
||||
*/
|
||||
if (cmds && cmds->cmd_type == PIPE)
|
||||
cmds = cmds->next;
|
||||
{
|
||||
nb++;
|
||||
}
|
||||
cmds = cmds->next;
|
||||
}
|
||||
return (nb);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/19 14:09:44 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/03 14:07:43 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/05/06 09:58:11 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -87,6 +87,8 @@ int get_out_type(t_msh *msh, t_cmd *cur_cmd)
|
||||
int ret;
|
||||
|
||||
msh->out_type = CMD;
|
||||
if (msh->out_fd > 2)
|
||||
close(msh->out_fd);
|
||||
msh->out_fd = 0;
|
||||
ret = 0;
|
||||
go_to_next_out_type(&cur_cmd);
|
||||
|
Reference in New Issue
Block a user