[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.