in reply to fork more than MaxSessions times in Net::OpenSSH

It seems that once the MaxSessions limit is reached, the SSH client tries to establish a new connection.

As a workaround, the following hack seems to work, just making the command fail:

my $ssh = Net::OpenSSH->new( $host ); push @{$ssh->{_ssh_opts}}, '-oConnectionAttempts=0'; ...
After the capture method call, in case of too many session, $ssh->error will be OSSH_SLAVE_CMD_FAILED and $? == 255.

I will add some option to the constructor to allow for setting slave ssh arguments without fiddling with the object interiors.

Anyway, instead of forking and unlimited number of processes, you could also use Parallel::ForkManager or Proc::Queue to get it under control.

update: I have just released version 1.53_04 that allows to set default slave ssh options as follows:

my $ssh = Net::OpenSSH->new($host, default_ssh_opts => [-o => 'ConnectionAtte +mpts=0'], ...);

Replies are listed 'Best First'.
Re^2: fork more than MaxSessions times in Net::OpenSSH
by morya (Initiate) on Sep 02, 2011 at 08:06 UTC

    Never thought of getting rely from the author~</>

    Yeah~

    Thanks a lot for such a quick answer!

    Going to check out Parallel::ForkManager and Proc::Queue ~