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-changelog

[Xen-changelog] [xen-unstable] Set FD_CLOEXEC on the pidfile fd, so that

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Set FD_CLOEXEC on the pidfile fd, so that tapdisk does not get it.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Dec 2006 12:50:15 +0000
Delivery-date: Thu, 14 Dec 2006 04:49:45 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID d2f12edc10eea829f766264c66d4e66d6d2a313a
# Parent  ac51e8f371083af035d03321d2e59d42ea080e26
Set FD_CLOEXEC on the pidfile fd, so that tapdisk does not get it.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/blktap/drivers/blktapctrl.c |   13 +++++++++++++
 1 files changed, 13 insertions(+)

diff -r ac51e8f37108 -r d2f12edc10ee tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Thu Dec 14 10:29:44 2006 +0000
+++ b/tools/blktap/drivers/blktapctrl.c Thu Dec 14 10:31:31 2006 +0000
@@ -629,6 +629,7 @@ static void write_pidfile(long pid)
        char buf[100];
        int len;
        int fd;
+       int flags;
 
        fd = open(PIDFILE, O_RDWR | O_CREAT, 0600);
        if (fd == -1) {
@@ -639,6 +640,18 @@ static void write_pidfile(long pid)
        /* We exit silently if daemon already running. */
        if (lockf(fd, F_TLOCK, 0) == -1)
                exit(0);
+
+       /* Set FD_CLOEXEC, so that tapdisk doesn't get this file
+          descriptor. */
+       if ((flags = fcntl(fd, F_GETFD)) == -1) {
+               DPRINTF("F_GETFD failed (%d)\n", errno);
+               exit(1);
+       }
+       flags |= FD_CLOEXEC;
+       if (fcntl(fd, F_SETFD, flags) == -1) {
+               DPRINTF("F_SETFD failed (%d)\n", errno);
+               exit(1);
+       }
 
        len = sprintf(buf, "%ld\n", pid);
        if (write(fd, buf, len) != len) {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Set FD_CLOEXEC on the pidfile fd, so that tapdisk does not get it., Xen patchbot-unstable <=