-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Submission type
- Bug report
systemd version the issue has been seen with
systemd-233-6.fc26.x86_64
Used distribution
Fedora 26
In case of bug report: Expected behaviour you didn't see
systemctl stop should show if my service transitions to state failed instead of inactive.
The documentation explicitly mentions services with ExecStop and no ExecStart. So we expect support for "services" that are implemented negatively, i.e. only affect the system when stopped. Similarly there's a pattern of one-shot service units where ExecStop is not limited to cleanup, e.g. [email protected] "Load/Save backlight".
If saving the backlight fails when running systemctl stop, it is a failure which should be reported to the user. And for a service which only has ExecStop, it doesn't seem to make sense that you could never see an error from running systemctl start/stop.
Even if ExecStop is just doing some cleanup, failures are still interesting.
It's possible the ExecStop failure could be a factor in the failure of a service restart, but only the later error would be shown, which would be misleading. I'm not certain what the correct behaviour is in this case, however. I want restart to show the ExecStop error... but if it then goes ahead with running ExecStart anyway, we need a message to say that. Otherwise, if ExecStart succeeds, we will keep quiet in traditional Unix fashion, but the user will see the previous error message and assume the service was not restarted. If we could redefine restart so it doesn't proceed after ExecStop fails, that would also solve the problem, but that doesn't quite sound like a good idea to me.
In case of bug report: Unexpected behaviour you saw
systemctl stop returns EXIT_SUCCESS and shows no message, when my service enters state failed instead of inactive.
In case of bug report: Steps to reproduce the problem
# systemctl cat test.service
# /etc/systemd/system/test.service
[Service]
Type=oneshot
ExecStop=/bin/false
RemainAfterExit=yes
# systemctl start test.service
# echo $?
0
# systemctl stop test.service
# echo $?
0
systemctl status test.service
● test.service
Loaded: loaded (/etc/systemd/system/test.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2017-07-28 14:23:10 BST; 5s ago
Process: 11025 ExecStop=/bin/false (code=exited, status=1/FAILURE)
Jul 28 14:23:04 alan-laptop systemd[1]: Started test.service.
Jul 28 14:23:10 alan-laptop systemd[1]: Stopping test.service...
Jul 28 14:23:10 alan-laptop systemd[1]: test.service: Control process exited, code=exited status=1
Jul 28 14:23:10 alan-laptop systemd[1]: Stopped test.service.
Jul 28 14:23:10 alan-laptop systemd[1]: test.service: Unit entered failed state.
Jul 28 14:23:10 alan-laptop systemd[1]: test.service: Failed with result 'exit-code'.
# systemctl restart test.service
# echo $?
0