in reply to Destructors when the program is stopped via a signal

I'm not too familiar with the mechanics of signals, but I think that
$SIG{INT} = sub { die "SIGINT\n" };
and
$SIG{INT} = sub { print STDERR "Exiting due to SIGINT\n"; exit(1) };
would cause Perl to exit while calling destructors.

Replies are listed 'Best First'.
Re^2: Destructors when the program is stopped via a signal
by weismat (Friar) on Mar 18, 2008 at 09:29 UTC
    This works fine for the main thread, but it does not call the destructor for objects in the detached child thread.
    Do you have a suggestion how to trigger this?
    I am usually using a detached thread pool where every child thread contains the one instance object.
      Just like you'd do if you wanted to exit the main program for any other reason. Send some kind of message to the threads that they need to terminate, and wait for them to terminate.