> -----Original Message-----
> From: Nathan Phillip Brink [mailto:[email protected]]
> Sent: Wednesday, July 22, 2009 7:27 AM
[ Snip ]
> Maybe I stated something unclearly before. Even though the
> courier.lock file I examined earlier pointed to the PID a
> running dkim-milter process, this same PID was being used by
> a courier-imapd daemon _before_ my computer unexpectedly
> rebooted. I am mostly interested in an automatic way of
> removing locks that get left in the filesystem after an
> unexpected reboot that covers the possibility of the PID
> being reclaimed by a non-courier-imapd process (that may
> possibly never exit until the machine reboots again).
I'm generally of the opinion that cleanup is best placed in the startup
scripts (e.g. /etc/init.d/whatever) rather than in the application proper.
One of the several reasons is that if you want more sophisticated cleanup
than a simple "rm -f /tmp/courier.lock" e.g. something like this...
PID=`some awk / cut / expr thing to extract the pid </tmp/courier.lock`
PSSTAT=`ps -edf | grep $PID`
if [ "$PSSTAT" != "" ]
then
PSPROC=`some awk / cut / expr thing to extract the process's
executable's name`
if [ "$PSPROC" = "courier-imap" ]
then
echo "You crazy? The daemon is already running."
exit 1
fi
fi
rm -f /tmp/courier.lock
... Then you'll want the ability to respond to the controlling terminal (the
echo) and return a useful error value, which is hard-er to do if you want to
detach and daemonize.
> binki
Malc.
------------------------------------------------------------------------------
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users