-
Problem report
-
Resolution: Fixed
-
Trivial
-
5.4.2
-
None
-
Debian GNU/Linux version 9 (Stretch), with systemd(1) as init system.
-
Sprint 78 (Jul 2021), Sprint 79 (Aug 2021), Sprint 80 (Sep 2021)
-
0.5
Currently the systemd service configuration files installed by Zabbix Debian packages contain the following line:
ExecStop=/bin/kill -SIGTERM $MAINPID
It works fine in most cases; but if the specified service has failed to start, for example, failed to bind(2) to its listing port, systemd(1) will invoke the ExecStop command line with $MAINPID expanded to empty, before trying to restart the service; the caused kill(1) to produce a long usage message in log, becasue no PID is specified; take service zabbix-agent for example, the log would be like:
Jul 15 12:56:23 x systemd[1]: Starting Zabbix Agent... Jul 15 12:56:23 x systemd[1]: zabbix-agent.service: Supervising process 69594 which is not our child. We'll most likely not notice when it exits. Jul 15 12:56:23 x systemd[1]: Started Zabbix Agent. Jul 15 12:56:23 x systemd[1]: zabbix-agent.service: Main process exited, code=exited, status=1/FAILURE Jul 15 12:56:23 x kill[69598]: Usage: Jul 15 12:56:23 x kill[69598]: kill [options] <pid> [...] Jul 15 12:56:23 x kill[69598]: Options: Jul 15 12:56:23 x kill[69598]: <pid> [...] send signal to every <pid> listed Jul 15 12:56:23 x kill[69598]: -<signal>, -s, --signal <signal> Jul 15 12:56:23 x kill[69598]: specify the <signal> to be sent Jul 15 12:56:23 x kill[69598]: -l, --list=[<signal>] list all signal names, or convert one to a name Jul 15 12:56:23 x kill[69598]: -L, --table list all signal names in a nice table Jul 15 12:56:23 x kill[69598]: -h, --help display this help and exit Jul 15 12:56:23 x kill[69598]: -V, --version output version information and exit Jul 15 12:56:23 x kill[69598]: For more details see kill(1). Jul 15 12:56:23 x systemd[1]: zabbix-agent.service: Control process exited, code=exited status=1 Jul 15 12:56:23 x systemd[1]: zabbix-agent.service: Unit entered failed state. Jul 15 12:56:23 x systemd[1]: zabbix-agent.service: Failed with result 'exit-code'.
These log messages will repeating every time the service process failed.
I suggest changing the ExecStop command line as followings, to avoid produce such confusing messages in log:
ExecStop=/bin/sh -c '[ -n "$1" ] && kill -s TERM "$1"' -- "$MAINPID"
In addition, the kill(1) command usage has changed silently for POSIX compliance; specifically, according to this page:
Values of signal_name shall be recognized in a case-independent fashion, without the SIG prefix.