Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Net::OpenSSH - page not loading completely

by comanche008 (Initiate)
on Apr 16, 2012 at 11:46 UTC ( #965294=note: print w/ replies, xml ) Need Help??


in reply to Re: Net::OpenSSH - page not loading completely
in thread Net::OpenSSH - page not loading completely

Tried this but did not work.

my %opts = ( user => 'root', batch_mode => 1, key_path => '~/.ssh/id_rsa', #passwd => '', ssh_cmd => '/usr/bin/ssh', default_stdin_fh => $def_in, #default_stdout_fh => $def_out, master_stdout_discard => 1, master_stderr_discard => 1, kill_ssh_on_timeout => 1, timeout => 5 );
I haven't found the file handle in question. Will need to read further how to track it. Thanks.


Comment on Re^2: Net::OpenSSH - page not loading completely
Download Code
Re^3: Net::OpenSSH - page not loading completely
by Eliya (Vicar) on Apr 16, 2012 at 13:27 UTC

    Just tried it (on Ubuntu, apache 2.2.20), and it worked fine for me, even without fiddling with the default_* / master_* options.   I.e., the ssh master connection etc. is automatically being terminated properly.

    Maybe enabling debugging

    $Net::OpenSSH::debug |= 0x7f;

    will shed some light on what isn't working in your case (output ends up in the webserver's error log).

      Thanks for the suggestions. The error "Pseudo-terminal will not be allocated because stdin is not a terminal." seems to be common. Below is the relevant part of the error log. The problem occurs frequently but not every single time the page is loaded.
      # open_ex: ['/usr/bin/ssh','-S','/var/lib/wwwrun/.libnet-openssh-perl/ +root-192.168.100.8-20273-555951','-l','root','192.168.100.8','--'] Pseudo-terminal will not be allocated because stdin is not a terminal. # _waitpid(20296) => pid: 20296, rc: # open_ex: ['/usr/bin/ssh','-O','check','-T','-S','/var/lib/wwwrun/.li +bnet-openssh-perl/root-192.168.100.8-20273-373748','-l','root','192.1 +68.100.8','--'] # waiting for slave, timeout: 5, remaining: 5, sleep: 1 # _waitpid(20299) => pid: 20299, rc: Interrupted system call # open_ex: ['/usr/bin/ssh','-S','/var/lib/wwwrun/.libnet-openssh-perl/ +root-192.168.100.8-20273-373748','-l','root','192.168.100.8','--'] Pseudo-terminal will not be allocated because stdin is not a terminal. # _waitpid(20300) => pid: 20300, rc: # open_ex: ['/usr/bin/ssh','-O','exit','-T','-S','/var/lib/wwwrun/.lib +net-openssh-perl/root-192.168.100.8-20273-373748','-l','root','192.16 +8.100.8','--'] # waiting for slave, timeout: 5, remaining: 5, sleep: 1 # _waitpid(20301) => pid: 20301, rc: Interrupted system call # open_ex: ['/usr/bin/ssh','-O','exit','-T','-S','/var/lib/wwwrun/.lib +net-openssh-perl/root-192.168.100.8-20273-555951','-l','root','192.16 +8.100.8','--'] # waiting for slave, timeout: 5, remaining: 5, sleep: 1 # _waitpid(20302) => pid: 20302, rc: Interrupted system call

        Looks like your system isn't automatically resuming interrupted system calls.1

        You could try modifying the module's code in order to do it manually.  Resuming a system call manually means to simply call it again if $! is EINTR or ERESTART.  In this particular case, look for line 755 in OpenSSH.pm

        $r = waitpid($pid, WNOHANG) and last;

        and modify it to read

        do { $r = waitpid($pid, WNOHANG); } while $r<0 and ($! == Errno::EINTR or $! == Errno::ERESTART); last if $r;

        This should take care of this particular waitpid call which produced the message in the debug log.  There are more, though, which would likely need a similar treatment, so it's probably best to get in touch with the module's author... (he frequents this place regularly, so he'll probably see the thread sooner or later, anyway).

        ___

        1 System calls may be interrupted for a variety of reasons. The more loaded a system, the more often it happens.  Most systems these days automatically resume them, so code isn't always written to handle the rare case where you have to do it manually...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://965294]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-12-22 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (112 votes), past polls