патчик для Net::SCP::Expect
Jul. 6th, 2006 03:54 pmВот что бывает, когда не маскируют глобальные переменные:
из "perldoc -f waitpid":
# perl -MNet::SCP::Expect -le 'print $?; $out = `ping -c1 localhost`; print $?;'
0
-1
#
из "perldoc -f waitpid":
waitpid PID,FLAGS
Waits for a particular child process to terminate and returns the pid
of the deceased process, or "-1" if there is no such child process.
On some systems, a value of 0 indicates that there are processes still
running. The status is returned in $?.
--- Expect.pm.orig 2006-07-06 15:49:48.296813218 +0300
+++ Expect.pm 2006-07-06 16:04:58.845077068 +0300
@@ -13,7 +13,7 @@
use Carp;
use Cwd;
-$SIG{CHLD} = \&reapChild;
+local $SIG{CHLD} = \&reapChild;
BEGIN{
use vars qw/$VERSION/;
@@ -271,6 +271,7 @@
}
sub reapChild{
+ local $?;
do {} while waitpid(-1,WNOHANG) > 0;
}
1;