The signals sent are customizable and that is documented in man systemd.kill
. The most interesting parts are:
KillSignal=
Specifies which signal to use when stopping a service. This
controls the signal that is sent as first step of shutting down a
unit (see above), and is usually followed by SIGKILL (see above
and below). For a list of valid signals, see signal(7). Defaults
to SIGTERM.
Note that, right after sending the signal specified in this
setting, systemd will always send SIGCONT, to ensure that even
suspended tasks can be terminated cleanly.
FinalKillSignal=
Specifies which signal to send to remaining processes after a
timeout if SendSIGKILL= is enabled. The signal configured here
should be one that is not typically caught and processed by
services (SIGTERM is not suitable). Developers can find it useful
to use this to generate a coredump to troubleshoot why a service
did not terminate upon receiving the initial SIGTERM signal. This
can be achieved by configuring LimitCORE= and setting
FinalKillSignal= to either SIGQUIT or SIGABRT. Defaults to
SIGKILL.
So when you systemctl stop *.service
, systemd will send a SIGTERM
by default to the main process in the service. If the process doesn't exit within TimeoutStopSec
(default 90s), then systemd
will follow up with a SIGKILL
.
When you are developing your application, you don't need to be too considerate about the init system. If you don't want to code a response to SIGTERM
, and want to simply keep SIGINT
, you can. You just need to ensure any systemd service files you ship contain KillSignal=SIGINT
.
I have not read anything to suggest systemd
skips KillSignal=
upon a reboot. If you ever see "Waiting for ..." when shutting down, that's systemd
waiting for things to respond to KillSignal
.