On Wed, 10 Jan 2001, Perrin Harkins wrote:
> Randal's solution is probably better, but it's a bummer that the parent
> doesn't run END blocks. Will it run cleanup handlers?
I'm pretty sure the parent runs END blocks. I just didn't want to have
the cleanup code run during child shutdown.
What I've done for now is this hack:
use vars qw($PID);
BEGIN
{
....
$PID = $$;
}
END
{
if ($$ == $PID )
{
# do cleanup
}
}
The only issue with that is what happens if the code is used in an
environment where a process starts up, forks a child, and then dies,
allowing the child to continue.
Hmm, I think I'll have to just doc it.
This is all related to clearing up an shared memory segment (and
semaphores) created by IPC::Shareable. Except I realized IPC::Shareable
can do it. Its just that for its boolean options it expects 'yes' or
'no', not 1 or 0. That's freaking brilliant. ARGH!
-dave
/*==================
www.urth.org
We await the New Sun
==================*/