-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_close.c
27 lines (24 loc) · 1.12 KB
/
ft_close.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_close.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbetz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/22 11:11:55 by rbetz #+# #+# */
/* Updated: 2023/02/22 11:30:36 by rbetz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_close_and_neg(int *fd)
{
close(*fd);
*fd = FD_UNUSED;
}
void ft_close_pipe_fds(int pipe[2])
{
if (pipe[READ] != FD_UNUSED)
ft_close_and_neg(&pipe[READ]);
if (pipe[WRITE] != FD_UNUSED)
ft_close_and_neg(&pipe[WRITE]);
}