Hi,

Could the OpenHPI client library by default set CLOSEXEC on sockets it opens? 
Our client spawns other processes, inheriting the open fds.

Thanks,
Rob Bubnis

$ cat patches/openhpi-2.14.1-cloexec.patch
--- openhpi-2.14.1/marshal/strmsock.cpp.orig    2010-01-05 12:17:58.000000000 
-0500
+++ openhpi-2.14.1/marshal/strmsock.cpp 2010-01-05 12:18:10.000000000 -0500
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -258,6 +259,17 @@
                return(TRUE);
        }

+        // set fd to close on exec
+        int flags;
+        flags = fcntl(s, F_GETFD);
+        if (flags == -1) {
+               errcode = errno;
+               close(s);
+               return(TRUE);
+       }
+        flags |= FD_CLOEXEC;
+        fcntl(s, F_SETFD, flags);
+
        errcode = 0;
        fOpen = TRUE;
        return(FALSE);
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Openhpi-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openhpi-devel

Reply via email to