Bug 721426 - systemd: systemctl status foo.service lies
Summary: systemd: systemctl status foo.service lies
Status: RESOLVED FIXED
Alias: None
Product: openSUSE 12.1
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Factory
Hardware: Other Other
: P5 - None : Major (vote)
Target Milestone: ---
Assignee: Frederic Crozat
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-30 08:52 UTC by Ludwig Nussel
Modified: 2011-10-12 08:55 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludwig Nussel 2011-09-30 08:52:20 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
Comment 1 Ludwig Nussel 2011-09-30 08:54:06 UTC
Note since init scripts are automatically wrapped through systemctl the usual rcfoo calls do not behave as expected either of course.
Comment 2 Frederic Crozat 2011-09-30 09:37:39 UTC
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".
Comment 3 Ludwig Nussel 2011-09-30 09:48:09 UTC
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.
Comment 4 Frederic Crozat 2011-09-30 11:29:40 UTC
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.
Comment 5 Frederic Crozat 2011-10-12 08:55:49 UTC
closing as fixed in openSUSE, although upstream is afraid of race condition with the patch.