Bug 188403 - anacron reported as dead but subsys locked
anacron reported as dead but subsys locked
Product: Fedora
Classification: Fedora
Component: anacron (Show other bugs)
All Linux
medium Severity low
: ---
: ---
Assigned To: Jason Vas Dias
Brock Organ
Depends On:
  Show dependency treegraph
Reported: 2006-04-09 01:20 EDT by Ian Laurie
Modified: 2009-01-21 19:10 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-04-24 20:25:29 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to use /var/lock/subsys/anacron.init lockfile within initscript (985 bytes, patch)
2009-01-21 19:10 EST, Japheth Cleaver
no flags Details | Diff

  None (edit)
Description Ian Laurie 2006-04-09 01:20:44 EDT
Description of problem:
The service command reports anacron as dead but subsys locked.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Issue command "service anacron status" or use GUI serice manager
Actual results:
Reports anacron as dead but subsys locked.

Expected results:
Should really report anacron is stopped.

Additional info:
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.
Comment 1 Jason Vas Dias 2006-04-13 21:03:55 EDT
This bug is now fixed, with anacron-2.3-38.FC[56] .

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.
Comment 2 Emerson House 2006-04-24 11:34:44 EDT
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
Comment 3 Ian Laurie 2006-04-24 20:25:29 EDT
anacron-2.3-38.FC5 from comment #1 has fixed the problem.
Comment 4 Fedora Update System 2006-05-03 14:51:53 EDT
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.
Comment 5 Kostas Georgiou 2006-06-23 09:34:03 EDT
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.
Comment 6 Japheth Cleaver 2009-01-21 19:10:00 EST
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.

Note You need to log in before you can comment on or make changes to this bug.