[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Set FD_CLOEXEC on the pidfile fd, so that tapdisk does not get it.
# 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |