summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/roken/cloexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/roken/cloexec.c')
-rw-r--r--source4/heimdal/lib/roken/cloexec.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source4/heimdal/lib/roken/cloexec.c b/source4/heimdal/lib/roken/cloexec.c
index c015b1d8fa..2d1fe033f2 100644
--- a/source4/heimdal/lib/roken/cloexec.c
+++ b/source4/heimdal/lib/roken/cloexec.c
@@ -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,21 @@ 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
+}
+
+void ROKEN_LIB_FUNCTION
+rk_cloexec_dir(DIR * d)
+{
+#ifndef _WIN32
+ rk_cloexec(dirfd(d));
+#endif
}