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] setsid() exception in xend

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] setsid() exception in xend
From: Horms <horms@xxxxxxxxxxxx>
Date: Sat, 26 Nov 2005 11:43:44 +0000 (UTC)
Delivery-date: Sat, 26 Nov 2005 11:45:41 +0000
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: tin/1.7.10-20050815 ("Grimsay") (UNIX) (Linux/2.6.14-2-686 (i686))
# HG changeset patch
# User Horms <horms@xxxxxxxxxxxx>
# Node ID 37d3e34dfdac009eac2bb040ff79ae711b2d50f9
# Parent  b9181b1c576fb39bb4d3b088ac3378d77163b4cc
For some reason that I can't quite put a finger on,
xend is a session leader well before the code in
SrvDaemon is called. This causes os.setsid() to
throw an exception.

This patch should be safe because the only exception
setsid should throw is if the current process is already
a session leader. So the process will either become 
a session leader, or will already be one.

Signed-Off-By: Horms <horms@xxxxxxxxxxxx>

diff -r b9181b1c576f -r 37d3e34dfdac tools/python/xen/xend/server/SrvDaemon.py
--- a/tools/python/xen/xend/server/SrvDaemon.py Sat Nov 26 01:21:55 2005
+++ b/tools/python/xen/xend/server/SrvDaemon.py Sat Nov 26 11:37:18 2005
@@ -123,8 +123,12 @@
 
     def daemonize(self):
         if not XEND_DAEMONIZE: return
-        # Detach from TTY.
-        os.setsid()
+       # Detach from TTY
+       try:
+               os.setsid()
+       except:
+               # Already a session leader
+               pass
 
         # Detach from standard file descriptors, and redirect them to
         # /dev/null or the log as appropriate.


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