[Mimedefang] /etc/init.d/mimedefang

David F. Skoll dfs at roaringpenguin.com
Wed Feb 28 09:15:58 EST 2007


Jeff Rife wrote:

> The crond script seems to be the only one to really get it right, with
> the following code:

> if [ -e /var/lock/subsys/crond ]; then
>   if [ -e /var/run/crond.pid ] && [ -e /proc/`cat /var/run/crond.pid` ]; then
>     echo -n $"cannot start crond: crond is already running.";
>     failure $"cannot start crond: crond already running.";
>     echo
>     return 1
>   fi
> fi

That's still a hack.  Process-IDs can be recycled.  The *only* safe way
to ensure a single copy of the daemon is for that daemon to open and
lock its PID file.  When another copy tries to lock the PID file, it will fail
and exit.

Because file locks are released when a process terminates (either
voluntarily or because of a crash), and because locks do not persist
across a reboot, it's the best way to do it.  However, very few
daemons actually do this (including mimedefang -- possibly an
enhancement for a future version?)

Regards,

David.



More information about the MIMEDefang mailing list