42-archive/42sh/libft/src/sys/dup2_close.c
2017-03-17 00:05:10 +01:00

22 lines
1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* dup2_close.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/07 16:07:28 by jhalford #+# #+# */
/* Updated: 2017/02/07 16:15:52 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int dup2_close(int fd1, int fd2)
{
if (dup2(fd1, fd2))
return (-1);
if (close(fd1))
return (-1);
return (0);
}