#define RB_SSL_CERTFP_LEN_SHA512 64
int rb_set_nb(rb_fde_t *);
+int rb_set_cloexec(rb_fde_t *);
+int rb_clear_cloexec(rb_fde_t *);
int rb_set_buffers(rb_fde_t *, int);
int rb_get_sockerr(rb_fde_t *);
return 1;
}
+int
+rb_set_cloexec(rb_fde_t *F)
+{
+#ifdef _WIN32
+ SetHandleInformation((HANDLE) F->fd, HANDLE_FLAG_INHERIT, 0);
+#else
+ int res;
+ rb_platform_fd_t fd;
+ if(F == NULL)
+ return 0;
+ fd = F->fd;
+
+ res = fcntl(fd, F_GETFD, NULL);
+ if(res == -1)
+ return 0;
+ if(fcntl(fd, F_SETFD, res | FD_CLOEXEC) == -1)
+ return 0;
+
+ return 1;
+#endif
+}
+
+int
+rb_clear_cloexec(rb_fde_t *F)
+{
+#ifdef _WIN32
+ SetHandleInformation((HANDLE) F->fd, HANDLE_FLAG_INHERIT, 1);
+#else
+ int res;
+ rb_platform_fd_t fd;
+ if(F == NULL)
+ return 0;
+ fd = F->fd;
+
+ res = fcntl(fd, F_GETFD, NULL);
+ if(res == -1)
+ return 0;
+ if(fcntl(fd, F_SETFD, res & ~FD_CLOEXEC) == -1)
+ return 0;
+
+ return 1;
+#endif
+}
+
/*
* rb_settimeout() - set the socket timeout
*