in reply to Make a perl script self aware...

Solution B, with a slight modification should work. As you pointed out, the only problem is with an error exit that doesnt clean up. To force cleanup, even on error, you could write your own die handler tat cleans up after itself.
$SIG{__DIE__} = { # call the clean up function, then die }
BTW: You don't actually need to store any data, just check for the files existence.

Replies are listed 'Best First'.
Re: Re: Make a perl script self aware...
by simonm (Vicar) on Aug 01, 2003 at 18:23 UTC

    To force cleanup, even on error, you could write your own die handler tat cleans up after itself.

    This is a step in the right direction, but unfortunately, this won't be invoked if your process is kill -9'd, or if the host is powered off abruptly, which is why the "check the PID to see if it's running" logic is still useful.