From: "Zhai, Edwin" Subject: [PATCH][VT]Don't leave vncviewer processes running if xm create fails Date: Mon, 15 Aug 2005 18:53:31 +0800 Message-ID: <4300742B.30700@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090803040403030105010701" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Pratt , Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------090803040403030105010701 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit this patch kill the created vncviewer process if xm create fails. --------------090803040403030105010701 Content-Type: text/plain; name="vncviewer.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="vncviewer.patch" Don't leave vncviewer processes running if xm create fails Signed-off-by: Edwin Zhai Signed-off-by: Arun Sharma --- a/tools/python/xen/xm/create.py Wed Aug 10 18:44:42 2005 +++ b/tools/python/xen/xm/create.py Thu Aug 11 18:44:59 2005 @@ -592,9 +592,14 @@ return d return None +vncpid = None + def spawn_vnc(display): - os.system("vncviewer -log *:stdout:0 -listen %d &" % - (VNC_BASE_PORT + display)) + vncargs = (["vncviewer" + "-log", "*:stdout:0", + "-listen", "%d" % (VNC_BASE_PORT + display) ]) + global vncpid + vncpid = os.spawnvp(os.P_NOWAIT, "vncviewer", vncargs) + return VNC_BASE_PORT + display def preprocess_vnc(opts, vals): @@ -639,6 +644,9 @@ else: dominfo = server.xend_domain_create(config) except XendError, ex: + import signal + if vncpid: + os.kill(vncpid, signal.SIGKILL) opts.err(str(ex)) dom = sxp.child_value(dominfo, 'name') --------------090803040403030105010701 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------090803040403030105010701--