Post by David HrbáÄPost by chris bso you know where to find them, though I don't
see much point to them anymore, unless you
want to run multiple instances and control
them independently because killproc doesn't
use pid files and stops all instances.
The point is that perl Net::Server detects stale PID files... And aborts
the execution.
(!)Net::Server: 2010/06/20-19:22:06 Pid_file already exists for running
process (3708)... aborting\n\n at line 277 in file
/usr/lib/perl5/vendor_perl/5.8.5/Net/Server.pm
Oh yes, I can see in the module. I've never used it tho.
Hmmm but amavisd doesn't use it either though.
On the other hand, amavisd does use its pid file.
It half validates it first, then uses it to stop anyone running
it more than once.
Doing a quick flick through the code
. . . [SNIP]
# is amavisd daemon already running?
. . . they're looking for a pid file . . .
if (defined $amavisd_pid && defined $mtime) { # got a PID from a file
# Is pid file older than system uptime? If so, it should be
disregarded,
# it must not prevent starting up amavisd after unclean shutdown.
my($now) = time; my($uptime,$uptime_fmt); # sys uptime in seconds
. . . now found a pid file which was created afer the last boot . .
if (!kill(0,$amavisd_pid)) { # does a process exist?
$! == ESRCH or die "Can't send SIG 0 to process [$amavisd_pid]:
$!";
undef $amavisd_pid; # process does not exist
. . . does the process with this pid exist, and are we starting or
stopping ??
# act on command line parameter in $cmd
my($killed_amavisd_pid); my($kill_sig_used);
if ($cmd =~ /^(?:start|debug|debug-sa|foreground)?\z/) {
!defined($amavisd_pid)
or die "The amavisd daemon is already running, PID:
[$amavisd_pid]\n";
. . . start being the default if nothing is on the command line . . .
Well
This means amavisd checks to see if a "valid" pid file exists,
( that is to say one of the correct name in the correct place,
contining a number, which was created after the last boot )
and if that's all ok, that a process with that pid is running.
If this is the case then it won't start, but it will restart or stop.
This illustrates the other issue with pif files, because if the
process crashes leaving a pid file behind and then
subsequently another different process starts which gets
allocated the old process number, then you won't be able
to start amavisd.
Oh well, i suppose it doesn't happen very often !!
My view is that ALL pid files should be below
/var/run/
which looks like what Dag was aiming at with his init script.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.repoforge.org/pipermail/users/attachments/20100622/afcfcadc/attachment-0004.html>