summaryrefslogtreecommitdiff
path: root/lib/tevent/tevent_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tevent/tevent_util.c')
-rw-r--r--lib/tevent/tevent_util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/tevent/tevent_util.c b/lib/tevent/tevent_util.c
index f78cd8f707..16af8f3b90 100644
--- a/lib/tevent/tevent_util.c
+++ b/lib/tevent/tevent_util.c
@@ -88,3 +88,20 @@ int ev_set_blocking(int fd, bool set)
return fcntl( fd, F_SETFL, val);
#undef FLAG_TO_SET
}
+
+bool ev_set_close_on_exec(int fd)
+{
+#ifdef FD_CLOEXEC
+ int val;
+
+ val = fcntl(fd, F_GETFD, 0);
+ if (val >= 0) {
+ val |= FD_CLOEXEC;
+ val = fcntl(fd, F_SETFD, val);
+ if (val != -1) {
+ return true;
+ }
+ }
+#endif
+ return false;
+}