|
Try joining the threads after you 'kill' them instead of detaching:
local $SIG{'KILL'} = sub {
threads->exit();
};
....
sub kill_loose_threads {
# Send signals first
foreach my $thread (threads->list()) {
$thread->kill('KILL');
}
# Join up with the terminating threads
foreach my $thread (threads->list()) {
$thread->join();
}
}
Also, add an explicit 'exit(0);' after the 'main();' call at the bottom of the script. |