I'm trying to use Daemon::Generic, and it seems to be exactly what I need, except on Solaris it seems that locking the pid file doesn't work. As a result, status
always reports the process is dead, even when it is quite clearly alive.
For example, the following:
use Daemon::Generic;
sub gd_run
{
sleep (60);
}
sub gd_preconfig
{
return ();
}
newdaemon(pidfile => "/tmp/myproc.pid");
... always reports the process is dead.
Note that /tmp
is mounted locally, so it seems like that should avoid issues with locks over network drives.
Any ideas how to get this to work?
Edit:
On closer investigation, by putting sleep 60
commands at various points in Generic.pm
, that it seems the lock is lost somewhere in the function gd_daemonize
. Do locks not survive forks on Solaris? Is there a way to ensure the lock survives the daemonize
process?