Wise Monks, I have been trying to use Net::OpenSSH to create shared pipes across a SSH session. These are used to pass simple ASCII messages back and forth across servers. In total, there are 8 of these SSH sessions created using Net::OpenSSH as such:

my %con_opts; $con_opts{host} = $host; $con_opts{timeout} = 120; $con_opts{async} = 1; $ssh{'SSH'} = Net::OpenSSH->new(%con_opts); # For Net::OpenSSH need to specify whether to create # pipes or not, default is no pipes. my %opts; $opts{stdin_pipe} = 1; $opts{stdout_pipe} = 1; $opts{stderr_to_stdout} = 1; # Kick off the script on the remote machine ($ssh{'STDIN'}, $ssh{'STDOUT'}, undef, $ssh{'PID'}) = $ssh{'SSH'}->open_ex(\%opts, $script) or die "Error ".$ssh{$host}->error;
And the STDOUT pipe is setup to be read asynchronously:
my $Q = new Thread::Queue; # Kick this off asynchronously to put things into the # queue to read whenever we get to it async{ while(<$pipe>) { $Q->enqueue( $_ ); } $Q->enqueue( undef ); }->detach; return $Q;

The problem is that seemingly at random, a (or more than 1) Net::OpenSSH SSH session will just terminate. This forces *all* existing Net::OpenSSH SSH sessions to terminate.

Wise Monks, any idea what's going on here to cause the premature exits? Many Thanks


In reply to Net::OpenSSH premature session termination by troy99

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.