Add cloexec() and xfree() to libroken
This commit is contained in:

committed by
Love Hornquist Astrand

parent
5dd6355e56
commit
7ee1695f12
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user