http://www.perlmonks.org?node_id=842372


in reply to Re^2: Proc::PID::File problem generating pid files, or: does it matter where a pid file lives?
in thread Proc::PID::File problem generating pid files, or: does it matter where a pid file lives?

The PID file also serves another purpose: it allows external resources to communicate with the service in a specified manner.
I would say, that's the only reason to use PID files. There's no need to use PID files to prevent simultaneous access to resources; for that, lock files are enough. And if all you care about is preventing concurrent running of the same program (which is what the OP needs), all you need to do is obtain a lock on yourself (no external files needed):
flock DATA, LOCK_EX or die "Another instance is already running";
  • Comment on Re^3: Proc::PID::File problem generating pid files, or: does it matter where a pid file lives?
  • Download Code