Bugzilla – Bug 721426
systemd: systemctl status foo.service lies
Last modified: 2011-10-12 08:55:49 UTC
For sysv services systemctl status reports active even when the daemon exited: nscd.service - LSB: Start Name Service Cache Daemon Loaded: loaded (/etc/init.d/nscd) Active: active (running) since Fri, 30 Sep 2011 08:50:22 +0200; 1s ago Process: 6667 ExecStop=/etc/init.d/nscd stop (code=exited, status=0/SUCCESS) Process: 6678 ExecStart=/etc/init.d/nscd start (code=exited, status=0/SUCCESS) Main PID: 6686 (nscd) CGroup: name=systemd:/system/nscd.service └ 6686 /usr/sbin/nscd blah:~ # echo $? 0 blah:~ # killall nscd blah:~ # systemctl status nscd.service nscd.service - LSB: Start Name Service Cache Daemon Loaded: loaded (/etc/init.d/nscd) Active: active (exited) since Fri, 30 Sep 2011 08:50:22 +0200; 22s ago Process: 6667 ExecStop=/etc/init.d/nscd stop (code=exited, status=0/SUCCESS) Process: 6678 ExecStart=/etc/init.d/nscd start (code=exited, status=0/SUCCESS) Main PID: 6686 (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/nscd.service blah:~ # echo $? 0 Moreover, systemctl start now doesn't start it anymore: blah:~ # systemctl start nscd.service blah:~ # echo $? 0 blah:~ # systemctl status nscd.service nscd.service - LSB: Start Name Service Cache Daemon Loaded: loaded (/etc/init.d/nscd) Active: active (exited) since Fri, 30 Sep 2011 08:50:22 +0200; 48s ago Process: 6667 ExecStop=/etc/init.d/nscd stop (code=exited, status=0/SUCCESS) Process: 6678 ExecStart=/etc/init.d/nscd start (code=exited, status=0/SUCCESS) Main PID: 6686 (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/nscd.service
Note since init scripts are automatically wrapped through systemctl the usual rcfoo calls do not behave as expected either of course.
unfortunately, LSB headers in initscripts is not providing PID filename which would help systemd to detect if a initscript is for an "daemon" or just for "action". This is why initscripts are started as if "RemainAfterExit=true" is set. I'm not sure if we should change this, since every initscript not starting daemon would be seen as "failed".
Couldn't systemd be smarter? I mean if the init script exits successfully with no daemon left behind then maybe it's "RemainAfterExit=true" indeed. If a daemon is left running it "RemainAfterExit=true" likely was wrong so it could reset it.
I've sent a patch which improves systemd behaviour to change RemainAfterExit depending if a daemon was started or not. http://lists.freedesktop.org/archives/systemd-devel/2011-September/003540.html I'm waiting for upstream decision on it.
closing as fixed in openSUSE, although upstream is afraid of race condition with the patch.