Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: Catching signals under Linux

by weismat (Friar)
on Jan 29, 2010 at 08:47 UTC ( #820320=note: print w/ replies, xml ) Need Help??

in reply to Re: Catching signals under Linux
in thread Catching signals under Linux

I can not really tell, but my guess is that it is the main thread...

Comment on Re^2: Catching signals under Linux
Replies are listed 'Best First'.
Re^3: Catching signals under Linux
by Anonymous Monk on Jan 29, 2010 at 08:55 UTC
    Um, guessing is not allowed :D
    #!/usr/bin/perl -- use strict; use warnings; use threads; use threads::shared; Main(@ARGV); exit(0); sub Main { local $SIG{'HUP'} = 'switchFlag'; share($::flag); $::flag = !!undef; # false my $thr = threads->new( \&printer ); $thr->detach(); sleep 10000; print threads->tid, " is here\n"; } ## end sub Main sub printer { while (1) { sleep 1; print threads->tid, " Shared: $::flag\n"; } } ## end sub printer sub switchFlag { $::flag = !$::flag; print threads->tid, " caught signal\n"; $SIG{'HUP'} = 'switchFlag'; }
      Nice one...Output from my box... 0 caught signal 0 is here ;-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://820320]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-11-25 18:04 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (684 votes), past polls