Hide Forgot
Description of problem: systemctl restart returns 0 even if given service fails during its restart. As an example I used openssh service (sshd). Both used versions of openssh have identical unit files. Version-Release number of selected component (if applicable): systemd-219-26.el7 How reproducible: always Steps to Reproduce: 1. echo 'AuthenticationMethods garbage' >>/etc/ssh/sshd_config 2. systemctl restart sshd 3. echo $? 4. systemctl status sshd Actual results: # echo 'AuthenticationMethods garbage' >>/etc/ssh/sshd_config # systemctl restart sshd # echo $? 0 # systemctl status sshd ● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Tue 2016-08-16 06:55:52 EDT; 8s ago Docs: man:sshd(8) man:sshd_config(5) Process: 1537 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255) Main PID: 1537 (code=exited, status=255) Aug 16 06:55:52 qeos-157 systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a Aug 16 06:55:52 qeos-157 systemd[1]: Unit sshd.service entered failed state. Aug 16 06:55:52 qeos-157 systemd[1]: sshd.service failed. Expected results: systemctl restart should return non-zero exit code. This actually worked in systemd-219-22.el7: # echo 'AuthenticationMethods garbage' >>/etc/ssh/sshd_config # systemctl restart sshd Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details. # echo $? 1 Additional info: I guess this behavior is caused by fix for BZ#1362461 (sshd has Restart=on-failure and quite big RestartSec delay: 42s).
Seems to be working with latest systemd. This is reproducible only in the case that the service is Type=Simple, but for those systemctl does not wait.