Tharg has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SFTP::Foreign + putty query ..
by salva (Canon) on Nov 12, 2009 at 22:06 UTC | |
by Tharg (Scribe) on Nov 13, 2009 at 09:09 UTC | |
by salva (Canon) on Nov 14, 2009 at 15:39 UTC | |
by Tharg (Scribe) on Nov 15, 2009 at 11:24 UTC | |
|
Re: Net::SFTP::Foreign + putty query ..
by peterdragon (Beadle) on Nov 13, 2009 at 15:26 UTC | |
by salva (Canon) on Nov 14, 2009 at 12:18 UTC |