this was already in tevent_util.c, but library layering prevented us
from using it in some other libraries
return fcntl( fd, F_SETFL, val);
#undef FLAG_TO_SET
}
+
+
+_PUBLIC_ bool 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;
+}
**/
_PUBLIC_ int set_blocking(int fd, bool set);
+/**
+ set close on exec on a file descriptor if available
+ **/
+_PUBLIC_ bool set_close_on_exec(int fd);
+
/**
Sleep for a specified number of milliseconds.
**/