WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] libxl: allow building without O_CLOEXEC definition

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] libxl: allow building without O_CLOEXEC definition
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Tue, 21 Jun 2011 08:52:49 +0100
Delivery-date: Tue, 21 Jun 2011 00:54:28 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -199,11 +199,25 @@ static int acquire_lock(void)
     fl.l_whence = SEEK_SET;
     fl.l_start = 0;
     fl.l_len = 0;
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
     fd_lock = open(lockfile, O_WRONLY|O_CREAT|O_CLOEXEC, S_IWUSR);
     if (fd_lock < 0) {
         fprintf(stderr, "cannot open the lockfile %s errno=%d\n", lockfile, 
errno);
         return ERROR_FAIL;
     }
+#if !O_CLOEXEC
+    {
+        int flags = fcntl(fd_lock, F_GETFD);
+
+        if (flags < 0 ||
+            fcntl(fd_lock, F_SETFD, flags | FD_CLOEXEC) < 0)
+            fprintf(stderr,
+                    "cannot mark lockfile %s close-on-exec errno=%d\n",
+                    lockfile, errno);
+    }
+#endif
 get_lock:
     rc = fcntl(fd_lock, F_SETLKW, &fl);
     if (rc < 0 && errno == EINTR)



Attachment: tools-no-O_CLOEXEC.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] libxl: allow building without O_CLOEXEC definition, Jan Beulich <=