Bug 1048123

Summary: `systemctl start' returns 0 despite not starting anything
Product: Red Hat Enterprise Linux 7 Reporter: Miroslav Franc <mfranc>
Component: glibcAssignee: Siddhesh Poyarekar <spoyarek>
Status: CLOSED CURRENTRELEASE QA Contact: Arjun Shankar <ashankar>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.0CC: ashankar, codonell, fweimer, lnykryn, mcermak, mnewsome, ohudlick, pfrankli, spoyarek, systemd-maint-list, tim
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: glibc-2.17-50.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1070416 (view as bug list) Environment:
Last Closed: 2014-06-13 12:54:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miroslav Franc 2014-01-03 09:07:15 UTC
Description of problem:

I would expect non-zero return status in case `systemctl start' is unable to start my service.


Version: systemd-207-9.el7


# systemctl status nscd
nscd.service - Name Service Cache Daemon
   Loaded: loaded (/usr/lib/systemd/system/nscd.service; disabled)
   Active: failed (Result: start-limit) since Fri 2014-01-03 03:55:07 EST; 17s ago
  Process: 17138 ExecStop=/usr/sbin/nscd --shutdown (code=exited, status=1/FAILURE)
  Process: 17136 ExecStart=/usr/sbin/nscd --foreground $NSCD_OPTIONS (code=exited, status=1/FAILURE)
 Main PID: 17136 (code=exited, status=1/FAILURE)

# systemctl start nscd
# echo $?
0
# systemctl status nscd
nscd.service - Name Service Cache Daemon
   Loaded: loaded (/usr/lib/systemd/system/nscd.service; disabled)
   Active: failed (Result: start-limit) since Fri 2014-01-03 03:55:29 EST; 9s ago
  Process: 17168 ExecStop=/usr/sbin/nscd --shutdown (code=exited, status=1/FAILURE)
  Process: 17166 ExecStart=/usr/sbin/nscd --foreground $NSCD_OPTIONS (code=exited, status=1/FAILURE)
 Main PID: 17166 (code=exited, status=1/FAILURE)

Comment 2 Lukáš Nykrýn 2014-01-07 13:50:55 UTC
Nscd.service is Type=simple. This option is for well-behaved daemon which can handle error situation by itself and does not quit. For this type systemctl considers that start action was successful in the case that the binary was started.

Solution here is to change ncsd daemon to handle error situations or change type to forking and remove the --foreground parameter.

Comment 5 Timothée Ravier 2014-02-27 18:31:48 UTC
Another solution (as forking is not really necessary here): nscd would have to tell systemd at some point that it cannot start. This can be done by patching nscd to use sd_notify http://www.freedesktop.org/software/systemd/man/sd_notify.html and changing the unit type to notify.

Comment 6 Carlos O'Donell 2014-02-27 19:05:18 UTC
(In reply to Timothée Ravier from comment #5)
> Another solution (as forking is not really necessary here): nscd would have
> to tell systemd at some point that it cannot start. This can be done by
> patching nscd to use sd_notify
> http://www.freedesktop.org/software/systemd/man/sd_notify.html and changing
> the unit type to notify.

We do not wish to patch nscd to depend on systemd, instead we are going to switch to forking with the parent waiting for the child to startup and the child providing an error code to the parent when startup is complete.

See the upstream discussion around here:
https://sourceware.org/ml/libc-alpha/2014-02/msg00747.html

We are going to have a solution in place that will make this work reliably.

Comment 17 Ludek Smid 2014-06-13 12:54:09 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.