[X2go-dev] x2goclient-cli don't terminates correctly?

Daniel Lindgren bd.dali at gmail.com
Fri Jan 7 10:36:41 CET 2011


> A quick and dirty solution would be to fix the perl script to take care of child processes and properly terminate them at exit.

... and here's my quick & dirty hack, add it after the last line in
x2goclient-cli:

# ---- CUT ----

my @SSHS = ();
my $ssh;
my $pid;
my @ssh_split = ();

# print "$0: Checking ssh sessions ...\n";
open(GR_SSH,"ps ux | grep \"ssh -p $port .*-N -L
$gr_port:localhost:$gr_port $user\@$server\" | grep -v grep |");
@SSHS = <GR_SSH>;
close(GR_SSH);

if ($sound) {
    open(SND_SSH,"ps ux | grep \"ssh -p $port .*-N -R
$snd_port:localhost:$snd_port $user\@$server\" | grep -v grep |");
    push(@SSHS,<SND_SSH>);
    close(SND_SSH);
}

if (scalar(@SSHS) > 0) {
    foreach $ssh (@SSHS) {
        $ssh =~ s/\s+/\|/g;
        @ssh_split = split(/\|/,$ssh);
        $pid = $ssh_split[1];
        # print "$0: Ending ssh session with pid $pid ...\n";
        system("kill -1 $pid");
    }
} else {
    # print "$0: No ssh sessions found.\n";
}

# ---- CUT ----

Don't know if there's a permanent solution in the works, the above
hack should do the job until then.

While testing I noticed that there are no hanging tunnels if I use SSH
keys to authenticate
(http://wiki.x2go.org/passwordless_authentication_using_ssh-keys), if
you don't want to modify  x2goclient-cli that might be a workaround.

Cheers,
Daniel



More information about the x2go-dev mailing list