in reply to Re^2: Gracefull Death of a Child: How to Catch Mum's SIGNALS?
in thread Gracefull Death of a Child: How to Catch Mum's SIGNALS?

As others have mentioned, threads are in a single process. So killing mum is killing darling. They're the same process, different thread.

In the code below, $SIG{$k} is local to the for block.

for my $k ( keys %SIG ) { local $SIG{$k} = sub { print "\n$$: Mum Caught \$SIG{ $k }\n" } }

For your own experience, try removing %SIG handlers from mum, and only put them in darling. Also, compare fork() to your threads.

JJ

Replies are listed 'Best First'.
Re^4: Gracefull Death of a Child: How to Catch Mum's SIGNALS?
by Anonymous Monk on Apr 05, 2007 at 10:34 UTC
    Well,
    as I wrote, I was playing around with local, to perform a
    kind of nothing-left-open-test - and nothing doesn't work.
    What is interessting is, that there is now an example at
    http://www.cpanforum.com/dist/threads that works,
    it causes the threads to break their sleep, and the signals SIGUSR1
    were set or thrown by mum.


    As soon as I changed it a bit (code even there) that signals from
    'outside' should be caught - it fails again: the SIGUSR1 were sent
    to the threads, mum waits,but the thread's sleep is not broken.


    So it seems this is something that Perl can't do!

    Surprised and and bit disappointed,
    Carl