in reply to Re^4: SIG{CHLD} altered by require statement on Perl 5.12.1
in thread SIG{CHLD} altered by require statement on Perl 5.12.1
I had to modify the code you recommended I run because it was giving me the following error:
Invalid version format (non-numeric data) at perlmonkII.pl line 7, nea +r "package SpyHash " syntax error at perlmonkII.pl line 9, near "package SpyHash {
Yepp, sorry, that's v5.14 syntax.
Then I ran this code on perl v.12.5 and I got
Assign to key CHLD at perlmonkII.pl line 34
So, it seems that Net::DNS does not modify $SIG{CHLD}. Or it does modify it so far behind the scenes that tie magic does not catch it.
Are you sure that your code does not mess with $SIG{CHLD}? Search all your sources for CHLD or $SIG.
Let's assume your code is clean. I added some calls to Data::Dumper to that code to verify the value of $SIG{CHLD}. Could you try that script? Comment out the tie %SIG,'SpyHash'; line and run again, so that we can see if tie has any effects.
#!/usr/bin/perl use v5.12; use strict; use warnings; use Data::Dumper; package SpyHash; use Tie::Hash; # for Tie::StdHash use Carp qw( carp ); our @ISA=qw( Tie::StdHash ); sub STORE{ my ($self,$key,$value)=@_; $key=~/^CH?LD$/ and carp "Assign to key $key"; return $self->SUPER::STORE($key,$value); } sub DELETE { my ($self,$key)=@_; $key=~/^CH?LD$/ and carp "Delete key $key"; return $self->SUPER::DELETE($key); } 1; package main; sub info { my $where=shift; print $where,": ",Dumper($SIG{'CHLD'}),"\n"; } info('start'); tie %SIG,'SpyHash'; info('after tie'); $SIG{'CHLD'}=sub { 'just a dummy' }; # this line should be reported info('after set handler'); require Net::DNS; # Any module messing with $SIG{'CHLD'} should be rep +orted from here info('after require'); Net::DNS->import(); # ... or here info('after import'); # For some extra paranoia, pretend to do some work with Net::DNS: my $dns=Net::DNS::Resolver->new(); info('after creating instance'); my $reply=$dns->search('localhost'); info('after resolving localhost'); $reply=$dns->search('no.such.host.anywhere.invalid.'); info('after resolving junk');
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: SIG{CHLD} altered by require statement on Perl 5.12.1
by sdingare (Initiate) on Apr 17, 2015 at 19:40 UTC | |
by sdingare (Initiate) on Apr 17, 2015 at 19:57 UTC | |
by afoken (Chancellor) on Apr 17, 2015 at 22:15 UTC | |
by sdingare (Initiate) on Apr 23, 2015 at 14:45 UTC | |
by afoken (Chancellor) on Apr 23, 2015 at 16:08 UTC |