From c79721e81acd05fdd9024447853d3fb090fc8325 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 12 Dec 2011 16:25:53 +0000 Subject: [PATCH] fix hang running xcat commands using ssh from MN on SN git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11215 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/xcatDBcmds | 2 +- xCAT-client/bin/xcatclient | 25 +++++++++++++++++++++---- xCAT-client/bin/xcatclientnnr | 24 +++++++++++++++++++----- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/xCAT-client/bin/xcatDBcmds b/xCAT-client/bin/xcatDBcmds index e3f595c06..4020db879 100755 --- a/xCAT-client/bin/xcatDBcmds +++ b/xCAT-client/bin/xcatDBcmds @@ -54,7 +54,7 @@ else $cmdref->{cwd}->[0] = cwd(); # get info from files piped in as stdin my $data; -if (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) +if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) ) { my $rin=""; vec($rin,fileno(STDIN),1)=1; diff --git a/xCAT-client/bin/xcatclient b/xCAT-client/bin/xcatclient index 8db1d2c7a..3f5c3c0ac 100755 --- a/xCAT-client/bin/xcatclient +++ b/xCAT-client/bin/xcatclient @@ -23,11 +23,28 @@ if ($bname =~ /xcatclient/) { $cmdref->{command}->[0]=shift @ARGV; } # xcatclie else { $cmdref->{command}->[0] = $bname; } # the cmd was sym linked to xcatclient $cmdref->{cwd}->[0] = cwd(); -if (-p STDIN) { - my $data; - while ( ) { $data.=$_; } - $cmdref->{stdin}->[0]=$data; + +# allows our plugins to get the stdin of the cmd that invoked the plugin +if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM +'}) ) +{ + my $rin=""; + vec($rin,fileno(STDIN),1)=1; + my $nfound=select($rout=$rin,"","",1); + if ($nfound) + { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } } +else +{ + if (-p STDIN) { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } +} + my $arg; my @tmpargv = @ARGV; diff --git a/xCAT-client/bin/xcatclientnnr b/xCAT-client/bin/xcatclientnnr index 4462369b1..df1165117 100755 --- a/xCAT-client/bin/xcatclientnnr +++ b/xCAT-client/bin/xcatclientnnr @@ -17,12 +17,26 @@ my $cmdref; if ($bname =~ /xcatclientnnr/) { $cmdref->{command}->[0]=shift @ARGV; } # xcatclientnnr was invoked directly and the 1st arg is cmd name that is used to locate the plugin else { $cmdref->{command}->[0] = $bname; } # the cmd was sym linked to xcatclientnnr $cmdref->{cwd}->[0] = cwd(); - -if (-p STDIN) { - my $data; - while ( ) { $data.=$_; } - $cmdref->{stdin}->[0]=$data; +# allows our plugins to get the stdin of the cmd that invoked the plugin +if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) ) +{ + my $rin=""; + vec($rin,fileno(STDIN),1)=1; + my $nfound=select($rout=$rin,"","",1); + if ($nfound) + { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } } +else +{ + if (-p STDIN) { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } +} + push (@{$cmdref->{arg}}, @ARGV); foreach (keys %ENV) {