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 the close-on-exec flag on the xenstor

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Set the close-on-exec flag on the xenstore fd in libxenstore.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 15 Aug 2006 20:30:25 +0000
Delivery-date: Tue, 15 Aug 2006 13:34:04 -0700
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 kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID fdc4531aefe06f7092e6c2113be76cbefaf77bf2
# Parent  59adc1f7dfca2e3182289fa2d422ddf1810016e9
Set the close-on-exec flag on the xenstore fd in libxenstore.
Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tools/xenstore/xs.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff -r 59adc1f7dfca -r fdc4531aefe0 tools/xenstore/xs.c
--- a/tools/xenstore/xs.c       Tue Aug 15 16:25:04 2006 +0100
+++ b/tools/xenstore/xs.c       Tue Aug 15 16:25:39 2006 +0100
@@ -101,23 +101,31 @@ static int get_socket(const char *connec
 static int get_socket(const char *connect_to)
 {
        struct sockaddr_un addr;
-       int sock, saved_errno;
+       int sock, saved_errno, flags;
 
        sock = socket(PF_UNIX, SOCK_STREAM, 0);
        if (sock < 0)
                return -1;
 
+       if ((flags = fcntl(sock, F_GETFD)) < 0)
+               goto error;
+       flags |= FD_CLOEXEC;
+       if (fcntl(sock, F_SETFD, flags) < 0)
+               goto error;
+
        addr.sun_family = AF_UNIX;
        strcpy(addr.sun_path, connect_to);
 
-       if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
-               saved_errno = errno;
-               close(sock);
-               errno = saved_errno;
-               return -1;
-       }
+       if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0)
+               goto error;
 
        return sock;
+
+error:
+       saved_errno = errno;
+       close(sock);
+       errno = saved_errno;
+       return -1;
 }
 
 static int get_dev(const char *connect_to)

_______________________________________________
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 the close-on-exec flag on the xenstore fd in libxenstore., Xen patchbot-unstable <=