Subject: | Net::OpenSSH not "use forks" safe |
Hi,
I've found a problem with Net::OpenSSH working in conjunction with use forks.
To reproduce, run the test attached to this case, first setting the string on line 52 in the test
to a valid user@host.
The problem seems to stem from line 392 inside the subroutine _kill_master when $sig ==
$TERM. Prior to this, die works as expected. Afterwards, die starts misbehaving in that
forked process. Eval calls come back with $@ set as an empty string when a die event
happens.
I'm not really following what's going on in this section of the code, so I can't really suggest a
fix. Any ideas how I might get this working?
Thanks,
Subject: | forks.t |
#!/usr/local/bin/perl -w
use forks;
use forks::shared;
use strict;
use Test::More;
my $dollar_at : shared;
my $thr;
my $obj;
#== Eval/die from sub inside object with OpenSSH ===
$dollar_at = undef;
$obj = open_ssh_test->new();
isa_ok($obj, "open_ssh_test");
$thr = threads->create({'exit' => 'thread_only'}, sub {
eval {
$obj->connect();
$obj->die_from_object;
};
$dollar_at = $@;
});
$thr->join();
like($dollar_at, qr/^Failure_message/, "\$\@ behaves fine in calls to Net::OpenSSH->new");
# Prove the issue is related to Net::OpenSSH by calling a sub without it;
$dollar_at = undef;
$thr = threads->create( sub {
eval {
$obj->die_from_object;
};
$dollar_at = $@;
});
$thr->join();
like($dollar_at, qr/^Failure_message/, "\$\@ behaves fine with object calls without ssh calls");
done_testing();
package open_ssh_test;
use Net::OpenSSH;
sub new {
my $class = shift;
my $self = {};
return bless($self, $class)
}
sub connect {
my $self = shift;
my $ssh = Net::OpenSSH->new('user@host');
die("Failure_message");
$self->{ssh} = $ssh;
}
sub die_from_object {
die("Failure_message");
}
1;