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

Net::SFTP::Foreign message on disconnect

by runrig (Abbot)
on Mar 06, 2013 at 17:08 UTC ( #1022042=perlquestion: print w/replies, xml ) Need Help??
runrig has asked for the wisdom of the Perl Monks concerning the following question:

When calling disconnect() from Net::SFTP::Foreign, the annoying message "Killed by signal 15." prints to STDERR. In looking for a way to get rid of that message, I came across:
..which works, but I wanted to set it in as small a scope as possible, but can anyone explain why this works:
my $sftp = do { local $SIG{TERM} = 'IGNORE'; Net::SFTP::Foreign->new( host => $host, user => $user, password => $pass, autodie => 1, ); }; $sftp->disconnect();
But this doesn't (actually I'm not clear on why even the first one works...I thought it would only affect signals that the perl process recieves...not the ssh process) :
my $sftp = do { #local $SIG{TERM} = 'IGNORE'; Net::SFTP::Foreign->new( host => $host, user => $user, password => $pass, autodie => 1, ); }; do { local $SIG{TERM} = 'IGNORE' $sftp->disconnect(); }
Update: It's pretty clear to me now...the new() forks/execs a new process with the signal mask set to ignore SIGTERM, so when you actually disconnect(), the completely separate process is still operating under the ignore SIGTERM signal mask, and has no knowledge of what perl's current signal mask is.

Replies are listed 'Best First'.
Re: Net::SFTP::Foreign message on disconnect
by salva (Abbot) on Mar 06, 2013 at 18:10 UTC
    the "Killed by signal 15" message is printed by the slave ssh. It seems that it doesn't reset the signal mask when it is started from the perl process.
Re: Net::SFTP::Foreign message on disconnect
by Anonymous Monk on Jun 05, 2013 at 09:55 UTC
    Thanks Runrig, that was exactly what I needed!
Re: Net::SFTP::Foreign message on disconnect
by Anonymous Monk on Sep 04, 2013 at 23:20 UTC
    Thank you. It also works for me but I was not using sftp->disconnect(), only the sftp->new. At the end of the script I used undef $sftp, it worked for linux OS but not for Soloris. It was annoying me a lot for long time.
      I ramdomly get "Killed by signal 15." on STDERR as well. I've added these two lines to see if this will resolve my issues. My next step will be to localize the signal.
      $sftp->disconnect; #try to avoid random error "Killed by signal 15." undef $sftp;
      $ rpm -q --whatprovides 'perl(Net::SFTP::Foreign)' perl-Net-SFTP-Foreign-1.75-1.el6.noarch

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1022042]
Approved by Corion
[LanX]: but I tend to just reject it by an apache rule
[shmem]: LanX: start a DDOS upon their servers :-P
[LanX]: well I could hack a honeypot xD
[LanX]: keeping them busy ... (diabolic laughter)
[Eily]: speaking of hacking
[Eily]: there's a new Mc Gyver series, with a hacker in the team
[Eily]: her skills are so good that they can be used to hack a pacemaker
[LanX]: team?
[Eily]: yup, he's part of a secret agent team or something like that
[Your Mother]: Haven't seen it, but let me guess. There is a woman and a minority agent and no Germans? Close? :P

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2018-03-19 14:35 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.