You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to create a simple script that uses Net::OpenSSH in cobination with AnyEvent. My AnyEvent installation uses EV, since it is the first choice of AnyEvent on the EvenLoop impementation.
Unfortunately I had to see that my script wasn't working but creating zombie childs. It seems that there is a race condition on the signal handlers. Singalhandling is global to the process, and EV does the signal handling in libev.
In the source of Net::OpenSSH you try to respect if $SIG{CHLD} is already set (probably by any other eventloop that uses $SIG{CHLD}). Maybe you could fix my issue with allowing EV to handle the singals in C-Land via an constructor option to Net::OpenSSH?
#!/usr/bin/env perl;
use common::sense;
use AnyEvent;
use AnyEvent::Util;
use Net::OpenSSH;
### If you use this $loop, you will create a ssh zombie
my $loop = AnyEvent->condvar;
my $ssh = Net::OpenSSH->new(
"localhost",
user => "ssh-test",
passwd => 'Kon4vl17',
async => 1
);
### IF you have the $loop here, everythign is fine
# my $loop = AnyEvent->condvar;
my $w;
$w = AnyEvent->timer( interval => 0.1, after => 0.1, cb => sub {
if ( $ssh->wait_for_master(1) ) {
# the connection has been established!
# remote commands can be run now
undef $w;
say "success";
my @cmd = $ssh->make_remote_command( echo => 'hello!' );
if (@cmd) {
my $out = '';
my $cv = AnyEvent::Util::run_cmd( \@cmd, '>' => \$out );
$cv->cb(sub {
say "command executed: $out";
undef $cv;
$loop->send;
});
}
else {
# something went wrong!
}
}
elsif ( $ssh->error ) {
# connection can not be established
undef $w;
say "conn failure";
}
});
$loop->recv;
The text was updated successfully, but these errors were encountered:
Hello,
I tried to create a simple script that uses
Net::OpenSSH
in cobination withAnyEvent
. My AnyEvent installation usesEV
, since it is the first choice of AnyEvent on the EvenLoop impementation.Unfortunately I had to see that my script wasn't working but creating zombie childs. It seems that there is a race condition on the signal handlers. Singalhandling is global to the process, and EV does the signal handling in libev.
In the source of Net::OpenSSH you try to respect if
$SIG{CHLD}
is already set (probably by any other eventloop that uses $SIG{CHLD}). Maybe you could fix my issue with allowing EV to handle the singals in C-Land via an constructor option to Net::OpenSSH?The text was updated successfully, but these errors were encountered: