On 02/15/2010 09:47 AM, Daniel P. Berrange wrote: > On Mon, Feb 15, 2010 at 09:39:31AM -0500, Cole Robinson wrote: >> On 02/15/2010 06:11 AM, Daniel P. Berrange wrote: >>> On Fri, Feb 12, 2010 at 10:32:17AM -0500, Cole Robinson wrote: >>>> This ugly thing is a shell script to detect availability of >>>> the -q option for 'nc': debian and suse based distros need this >>>> flag to ensure the remote nc will exit on EOF, so it will go away >>>> when we close the tunnel. If it doesn't go away, a useless 'nc' >>>> process is left sitting on the remote host. >>>> >>>> Fedora's 'nc' doesn't have this option, so we can't blindly pass -q. >>>> More info here: >>> >>> I don't really like this approach. Shouldn't it be sufficient to >>> just explicit SIGKILL the ssh client, rather than relying on the >>> exit-on-EOF behaviour of nc. >>> >> >> kill() helps prevent virt-manager from hanging, but it doesn't address the >> dangling 'nc' process on the remote host that requires -q. Every connection >> will leave an 'nc' process hanging. > > It does when I try it. Killing the SSH client connection results in SIGHUP > for the process running on the remote host & nc exits on SIGHUP. > Connecting to a debian system? I just tried using the attached patch on top of latest git (not my patches): Running virsh --connect URI to a debian lenny system, then invoking 'quit', leaves 'nc -U' processes running. 'quit' doesn't hang like it does with current git, but the nc process isn't closed on the remote host. Any recommendations? Thanks, Cole
>From 1cc53900cf6b176d8c8cf07f9d5c03b98b935c0c Mon Sep 17 00:00:00 2001 From: Cole Robinson <crobinso@xxxxxxxxxx> Date: Mon, 15 Feb 2010 11:27:37 -0500 Subject: [PATCH] Kill ssh tunnel --- src/remote/remote_driver.c | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 13534ce..b979efa 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -947,13 +947,7 @@ doRemoteOpen (virConnectPtr conn, close (priv->sock); #ifndef WIN32 if (priv->pid > 0) { - pid_t reap; - do { -retry: - reap = waitpid(priv->pid, NULL, 0); - if (reap == -1 && errno == EINTR) - goto retry; - } while (reap != -1 && reap != priv->pid); + kill(priv->pid, SIGKILL); } #endif } @@ -1411,13 +1405,7 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv) #ifndef WIN32 if (priv->pid > 0) { - pid_t reap; - do { -retry: - reap = waitpid(priv->pid, NULL, 0); - if (reap == -1 && errno == EINTR) - goto retry; - } while (reap != -1 && reap != priv->pid); + kill(priv->pid, SIGKILL); } #endif if (priv->wakeupReadFD >= 0) { -- 1.6.5.2
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list