summaryrefslogtreecommitdiff
path: root/man/systemd.kill.xml
blob: 73f61c80e4fdf28c5c9a5bf9f2a3556b8f334e9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->

<refentry id="systemd.kill">
  <refentryinfo>
    <title>systemd.kill</title>
    <productname>systemd</productname>
  </refentryinfo>

  <refmeta>
    <refentrytitle>systemd.kill</refentrytitle>
    <manvolnum>5</manvolnum>
  </refmeta>

  <refnamediv>
    <refname>systemd.kill</refname>
    <refpurpose>Process killing procedure
    configuration</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <para><filename><replaceable>service</replaceable>.service</filename>,
    <filename><replaceable>socket</replaceable>.socket</filename>,
    <filename><replaceable>mount</replaceable>.mount</filename>,
    <filename><replaceable>swap</replaceable>.swap</filename>,
    <filename><replaceable>scope</replaceable>.scope</filename></para>
  </refsynopsisdiv>

  <refsect1>
    <title>Description</title>

    <para>Unit configuration files for services, sockets, mount
    points, swap devices and scopes share a subset of configuration
    options which define the killing procedure of processes belonging
    to the unit.</para>

    <para>This man page lists the configuration options shared by
    these five unit types. See
    <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
    for the common options shared by all unit configuration files, and
    <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
    <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
    <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
    <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
    and
    <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>
    for more information on the configuration file options specific to
    each unit type.</para>

    <para>The kill procedure configuration options are configured in
    the [Service], [Socket], [Mount] or [Swap] section, depending on
    the unit type.</para>
  </refsect1>

  <refsect1>
    <title>Options</title>

    <variablelist class='unit-directives'>

      <varlistentry>
        <term><varname>KillMode=</varname></term>
        <listitem><para>Specifies how processes of this unit shall be killed. One of
        <option>control-group</option>, <option>mixed</option>, <option>process</option>,
        <option>none</option>.</para>

        <para>If set to <option>control-group</option>, all remaining processes in the control group of this
        unit will be killed on unit stop (for services: after the stop command is executed, as configured
        with <varname>ExecStop=</varname>). If set to <option>mixed</option>, the
        <constant>SIGTERM</constant> signal (see below) is sent to the main process while the subsequent
        <constant>SIGKILL</constant> signal (see below) is sent to all remaining processes of the unit's
        control group. If set to <option>process</option>, only the main process itself is killed (not
        recommended!). If set to <option>none</option>, no process is killed (strongly recommended
        against!). In this case, only the stop command will be executed on unit stop, but no process will be
        killed otherwise.  Processes remaining alive after stop are left in their control group and the
        control group continues to exist after stop unless empty.</para>

        <para>Note that it is not recommended to set <varname>KillMode=</varname> to
        <constant>process</constant> or even <constant>none</constant>, as this allows processes to escape
        the service manager's lifecycle and resource management, and to remain running even while their
        service is considered stopped and is assumed to not consume any resources.</para>

        <para>Processes will first be terminated via <constant>SIGTERM</constant> (unless the signal to send
        is changed via <varname>KillSignal=</varname> or <varname>RestartKillSignal=</varname>). Optionally,
        this is immediately followed by a <constant>SIGHUP</constant> (if enabled with
        <varname>SendSIGHUP=</varname>). If processes still remain after the main process of a unit has
        exited or the delay configured via the <varname>TimeoutStopSec=</varname> has passed, the termination
        request is repeated with the <constant>SIGKILL</constant> signal or the signal specified via
        <varname>FinalKillSignal=</varname> (unless this is disabled via the <varname>SendSIGKILL=</varname>
        option). See <citerefentry><refentrytitle>kill</refentrytitle><manvolnum>2</manvolnum></citerefentry>
        for more information.</para>

        <para>Defaults to <option>control-group</option>.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><varname>KillSignal=</varname></term>
        <listitem><para>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
        <constant>SIGKILL</constant> (see above and below). For a list of valid signals, see
        <citerefentry project='man-pages'><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
        Defaults to <constant>SIGTERM</constant>.</para>

        <para>Note that, right after sending the signal specified in this setting, systemd will always send
        <constant>SIGCONT</constant>, to ensure that even suspended tasks can be terminated cleanly.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><varname>RestartKillSignal=</varname></term>
        <listitem><para>Specifies which signal to use when restarting a service. The same as
        <varname>KillSignal=</varname> described above, with the exception that this setting is used in a
        restart job. Not set by default, and the value of <varname>KillSignal=</varname> is used.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><varname>SendSIGHUP=</varname></term>
        <listitem><para>Specifies whether to send
        <constant>SIGHUP</constant> to remaining processes immediately
        after sending the signal configured with
        <varname>KillSignal=</varname>. This is useful to indicate to
        shells and shell-like programs that their connection has been
        severed. Takes a boolean value. Defaults to "no".
        </para></listitem>
      </varlistentry>

      <varlistentry>
        <term><varname>SendSIGKILL=</varname></term>
        <listitem><para>Specifies whether to send
        <constant>SIGKILL</constant> (or the signal specified by
        <varname>FinalKillSignal=</varname>) to remaining processes
        after a timeout, if the normal shutdown procedure left
        processes of the service around. When disabled, a
        <varname>KillMode=</varname> of <constant>control-group</constant>
        or <constant>mixed</constant> service will not restart if
        processes from prior services exist within the control group.
        Takes a boolean value. Defaults to "yes".
        </para></listitem>
      </varlistentry>

      <varlistentry>
        <term><varname>FinalKillSignal=</varname></term>
        <listitem><para>Specifies which signal to send to remaining
        processes after a timeout if <varname>SendSIGKILL=</varname>
        is enabled. The signal configured here should be one that is
        not typically caught and processed by services (<constant>SIGTERM</constant>
        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 <constant>SIGTERM</constant>
        signal. This can be achieved by configuring <varname>LimitCORE=</varname>
        and setting <varname>FinalKillSignal=</varname> to either
        <constant>SIGQUIT</constant> or <constant>SIGABRT</constant>.
        Defaults to <constant>SIGKILL</constant>.
        </para></listitem>
      </varlistentry>

      <varlistentry>
        <term><varname>WatchdogSignal=</varname></term>
        <listitem><para>Specifies which signal to use to terminate the
        service when the watchdog timeout expires (enabled through
        <varname>WatchdogSec=</varname>). Defaults to <constant>SIGABRT</constant>.
        </para></listitem>
      </varlistentry>

    </variablelist>
  </refsect1>

  <refsect1>
      <title>See Also</title>
      <para>
        <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
        <citerefentry><refentrytitle>kill</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
        <citerefentry project='man-pages'><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>
      </para>
  </refsect1>

</refentry>