[gnutls-devel] gnutls 3.4 build failed to build on Solaris because of missing SOCK_CLOEXEC symbol

Ann Lai ann.lai at oracle.com
Thu May 14 00:38:06 CEST 2015


Hi,

gnutls 3.4.0 failed to build on Solaris systems because SOCK_CLOEXEC 
symbol.  Below is a proposed patch to fix.

--- ORIGINAL/./tests/utils.c    2015-05-07 17:10:15.668662904 -0700
+++ gnutls-3.4.0/./tests/utils.c        2015-05-07 18:33:41.145146750 -0700
@@ -33,6 +33,7 @@
  #include <netinet/in.h>
  #include <sys/types.h>
  #include <sys/socket.h>
+#include <fcntl.h>

  #include "utils.h"

@@ -187,8 +188,16 @@
                 .sin_port = 0
         };
         int fd;
+       int flags;

+#ifdef SOCK_CLOEXEC
         fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+#else
+       fd = socket(AF_INET, SOCK_DGRAM, 0);
+       flags = fcntl(fd, F_GETFD, 0);
+       if (flags >= 0)
+               fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+#endif
          setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on));
  #if defined(SO_REUSEPORT)
          setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (char*)&on, sizeof(on));

Thanks,
Ann



More information about the Gnutls-devel mailing list