Alexandre Julliard : ntdll: Avoid the close-on-exec race with recvmsg() on kernels that support this.

Alexandre Julliard julliard at winehq.org
Wed Jul 1 09:28:10 CDT 2009


Module: wine
Branch: master
Commit: 3269d8c726eb13925fe0d8cd571e8552ae348154
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3269d8c726eb13925fe0d8cd571e8552ae348154

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jul  1 12:11:53 2009 +0200

ntdll: Avoid the close-on-exec race with recvmsg() on kernels that support this.

---

 dlls/ntdll/server.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index a7bc493..9e54ada 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -73,6 +73,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(server);
 #define SCM_RIGHTS 1
 #endif
 
+#ifndef MSG_CMSG_CLOEXEC
+#define MSG_CMSG_CLOEXEC 0
+#endif
+
 #define SOCKETNAME "socket"        /* name of the socket file */
 #define LOCKNAME   "lock"          /* name of the lock file */
 
@@ -408,12 +412,12 @@ static int receive_fd( obj_handle_t *handle )
 
     for (;;)
     {
-        if ((ret = recvmsg( fd_socket, &msghdr, 0 )) > 0)
+        if ((ret = recvmsg( fd_socket, &msghdr, MSG_CMSG_CLOEXEC )) > 0)
         {
 #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
             fd = cmsg.fd;
 #endif
-            if (fd != -1) fcntl( fd, F_SETFD, 1 ); /* set close on exec flag */
+            if (fd != -1) fcntl( fd, F_SETFD, FD_CLOEXEC ); /* in case MSG_CMSG_CLOEXEC is not supported */
             return fd;
         }
         if (!ret) break;




More information about the wine-cvs mailing list