Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
detaches her childs:threads; threads::shared;
Well mum.pl catches the SIGNALS likeour $D = threads->new(\&Darling::run, ID => 'Darling' ); $D->detach(); ... while (my $client = $server->accept()) { #foreach $client my $pAddr = $client->peerhost(); ... }
But now I want Darling to die gracefully and I need to catch mums SIGNAL within Darling (by Darlin)!$SIG{KILL} = 'mumsDeath'; $SIG{TERM} = 'mumsDeath'; sub mumsDeath {$D->kill('KILL'); print "killing my darling\n";}
Carlpackage Darling; use threads; use threads::shared; our $minID; sub new { #: create Darling my $pkg = shift; my $self = { @_ }; return bless($self, $pkg); ##: arr of blessed (self, pkg) } sub catchBullet { print "\n\n$0 :: $minID SIGNAL caught !!\n"; } sub run { my $self = MinBar->new(@_); #: Me $minID = $self->{ID}; #: $|++; $SIG{TSTP} = 'catchBullet'; $SIG{INT} = 'catchBullet'; $SIG{TERM} = 'catchBullet'; $SIG{KILL} = 'catchBullet'; $SIG{QUIT} = 'catchBullet'; $SIG{STOP} = 'catchBullet'; $SIG{USR2} = 'catchBullet'; $SIG{USR1} = 'catchBullet'; print "$0 :: $minID starting: "; while ( 1 ) { sleep 30; print "." } }
|
|---|