Add cloexec() and xfree() to libroken

This commit is contained in:
Asanka Herath
2009-08-26 14:41:58 -04:00
committed by Love Hornquist Astrand
parent 5dd6355e56
commit 7ee1695f12
3 changed files with 7 additions and 6 deletions

View File

@@ -33,14 +33,12 @@
#include <config.h>
#include <unistd.h>
#include <fcntl.h>
#include "roken.h"
void ROKEN_LIB_FUNCTION
rk_cloexec(int fd)
{
#ifdef HAVE_FCNTL
int ret;
ret = fcntl(fd, F_GETFD);
@@ -48,10 +46,13 @@ rk_cloexec(int fd)
return;
if (fcntl(fd, F_SETFD, ret | FD_CLOEXEC) == -1)
return;
#endif
}
void ROKEN_LIB_FUNCTION
rk_cloexec_file(FILE *f)
{
#ifdef HAVE_FCNTL
rk_cloexec(fileno(f));
#endif
}