42_minishell/utils/fd.c

25 lines
326 B
C
Raw Normal View History

#include "./utils.h"
2023-03-13 14:29:20 -04:00
#include <stdio.h>
void ft_closer(int fds[2])
{
if (fds[0] > 2)
2023-03-13 14:29:20 -04:00
{
//dprintf(2, "close(%d)\n", fds[0]);
close(fds[0]);
2023-03-13 14:29:20 -04:00
}
if (fds[1] > 2)
2023-03-13 14:29:20 -04:00
{
//dprintf(2, "close(%d)\n", fds[1]);
close(fds[1]);
2023-03-13 14:29:20 -04:00
}
}
void ft_add_fd(int fds[2], int fd)
{
if (fds[0] == -1)
fds[0] = fd;
else
fds[1] = fd;
}