Red Hat Bugzilla – Bug 188403
anacron reported as dead but subsys locked
Last modified: 2009-01-21 19:10:00 EST
Description of problem:
The service command reports anacron as dead but subsys locked.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Issue command "service anacron status" or use GUI serice manager
Reports anacron as dead but subsys locked.
Should really report anacron is stopped.
Anacron isn't a real service as such, it runs at boot time then exits.
The srvice control script /etc/rc.d/init.d/anacron, in the 'start' and
'stop' function, creates and removes a lock file. Since anacron exits
by itself (not through the stop function) the lock file is created but
never destroyed, hence the service manager mechanisms report anacron
as dead with the subsystem locked, which is alarming, and untrue.
A quick check of RHEL3 and RHEL4 shows that those service scripts do NOT
use a lock file for anacron, which makes much more sense.
The easy solution is to comment out the lock file code in the service script.
This makes it work as in RHEL3 & 4.
This bug is now fixed, with anacron-2.3-38.FC .
Yes, the anacron process just exits when it has no more work to do, so
it is not amenable to SysVinit lock file management with initscripts.
The SysVinit maintainer did not like this, so added the lockfile creation
to the anacron initscript, which then causes problems when anacron exits
normally and the lock file still exists.
Now, the lock file management has been taken out of the initscript, and
the anacron process itself creates the /var/lock/subsys/anacron lock file,
and a /var/run/anacron.pid pid file, and removes them automatically at
exit (using atexit(3)) or if killed by the QUIT, TERM or USR1 signals.
Please try out the new version, soon to be released to FC-5 Updates/Testing,
and let me know of any issues - thanks.
This sounds similar to a problem I am having. My problem is that anacron does
not seem to run when hibernate is used, but I also notice the anacron dead but
subsys locked. However in looking through the init code I can see how anacron
is called during system startup, but not if it is ever called again if the
system is hibernated and not restarted. I could be I am missing something as I
am not a anacron expert, but the desireable process would be for anacron to
execute when a system is brought out of hibernation (and possibly out of standby
anacron-2.3-38.FC5 from comment #1 has fixed the problem.
anacron-2.3-38.FC5 has been pushed for fc5, which should resolve this issue. If these problems are still present in this version, then please make note of it in this bug report.
This has the side effect that you get:
Stopping anacron: [FAILED]
messages if anacron isn't running.
The best solution is probably to return success if $PIDFILE doesn't exist.
Created attachment 329675 [details]
Patch to use /var/lock/subsys/anacron.init lockfile within initscript
Anacron keeps going back and forth between use of SysV-style subsys locks, but I think the real solution is something like this.
/etc/rc.d/rc (which handles switching of runlevels) checks not only for /var/lock/subsys/$prog but for $prog.init as well. I couldn't find documentation on the original difference between $prog and $prog.init (perhaps a legacy catch?), but we can use this to our advantage here.
This patch modifies /etc/rc.d/init.d/anacron to specify /var/lock/subsys/anacron.init, since anacron takes care of /var/lock/subsys/anacron itself.
Testing with "/etc/rc.d/rc" on both the same and changed runlevels shows better behavior that continually running an anacron that has already had /etc/init.d/anacron start run without a corresponding 'stop' command.
A similar change could be achieved by modifying the LOCKFILE variable itself, but I wanted to make it absolutely clear what this patch did.