Hi Monks. I hope you will be able to help me with this problem.

I have a script that uses Net::SFTP::Foreign and, on Windows, Putty's plink.exe for the ssh connection.

Everything works fine when I am connected, but when I disconnect by undefining the object, plink.exe stays in my Processes for some time. This is particularly problematic for me because I'm connecting and disconnecting in a loop to poll for files, so after a while I have ~ 30 plink.exes going and then I seem to hit some limit that means I can't start any more.

I found this line in the Foreign.pm :

kill 1, $pid and waitpid($pid, 0);

That seems to be intended to kill it, but the pid it attempts to kill is not the pid of the putty process. The pid it has appears to have been gleaned form these lines :

do { local ($@, $SIG{__DIE__}, $SIG{__WARN__}); $sftp->{pid} = open2($sftp->{ssh_in}, $sftp->{ssh_out}, @open2 +_cmd) ; };

But I don't really understand them, to be honest. Perhaps the pid is not for putty but is for the pipe? (Again I don't really understand 'pipe'.)

Is this as intended, or am I being stupid, or is there a bug in Net::SFTP::Foreign? If it's intended, is there a good practice solution? I can't really change the way I'm polling the server in the loop becase it's part of a bigger library and process.

Thanks v much!


In reply to Net::SFTP::Foreign + putty query .. by Tharg

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.