exec: drop process group kill mode since it has little use and confuses the user

This commit is contained in:
Lennart Poettering 2011-03-29 23:31:38 +02:00
parent 12235040ec
commit cd25cce98f
18 changed files with 20 additions and 49 deletions

6
TODO
View File

@ -12,8 +12,6 @@ F15:
* hook emergency.target into local-fs.target in some way as OnFailure with isolate * hook emergency.target into local-fs.target in some way as OnFailure with isolate
* drop SIGHUP handling from rsyslog.service upstream (PENDING)
* teach dbus to activate all services it finds in /etc/systemd/services/org-*.service * teach dbus to activate all services it finds in /etc/systemd/services/org-*.service
* save/restore tool for SysV as requested by FPC (PENDING) * save/restore tool for SysV as requested by FPC (PENDING)
@ -27,8 +25,6 @@ F15:
* document default dependencies * document default dependencies
* remove KillMode=process-group
* kernel patch wegen kmsg prio nach f15 * kernel patch wegen kmsg prio nach f15
* LOG_DAEMON/LOG_USER für kmsg messages schreiben * LOG_DAEMON/LOG_USER für kmsg messages schreiben
@ -41,8 +37,6 @@ Features:
* when key file cannot be found, read it from kbd in cryptsetup * when key file cannot be found, read it from kbd in cryptsetup
* hide passwords on TAB
* get rid of random file name in generator directory? * get rid of random file name in generator directory?
/run/systemd/generator-IH1vFu /run/systemd/generator-IH1vFu

View File

@ -304,13 +304,11 @@
<command>kill</command>, choose the <command>kill</command>, choose the
mode how to kill the selected mode how to kill the selected
processes. Must be one of processes. Must be one of
<option>control-group</option>, <option>control-group</option> or
<option>process-group</option> or
<option>process</option> to select <option>process</option> to select
whether to kill the entire control whether to kill the entire control
group, the process group or only the group or only the selected process
selected process itself. If omitted itself. If omitted defaults to
defaults to
<option>control-group</option> if <option>control-group</option> if
<option>--kill-who=all</option> is <option>--kill-who=all</option> is
set, or <option>process</option> set, or <option>process</option>

View File

@ -221,7 +221,6 @@
processes of this mount shall be processes of this mount shall be
killed. One of killed. One of
<option>control-group</option>, <option>control-group</option>,
<option>process-group</option>,
<option>process</option>, <option>process</option>,
<option>none</option>.</para> <option>none</option>.</para>

View File

@ -558,7 +558,6 @@
processes of this service shall be processes of this service shall be
killed. One of killed. One of
<option>control-group</option>, <option>control-group</option>,
<option>process-group</option>,
<option>process</option>, <option>process</option>,
<option>none</option>.</para> <option>none</option>.</para>
@ -570,10 +569,6 @@
stop command (as configured with stop command (as configured with
<varname>ExecStop=</varname>) is <varname>ExecStop=</varname>) is
executed. If set to executed. If set to
<option>process-group</option> only
the members of the process group of
the main service process are
killed. If set to
<option>process</option> only the main <option>process</option> only the main
process itself is killed. If set to process itself is killed. If set to
<option>none</option> no process is <option>none</option> no process is

View File

@ -519,7 +519,6 @@
processes of this socket unit shall be processes of this socket unit shall be
killed. One of killed. One of
<option>control-group</option>, <option>control-group</option>,
<option>process-group</option>,
<option>process</option>, <option>process</option>,
<option>none</option>.</para> <option>none</option>.</para>

View File

@ -175,7 +175,6 @@
processes of this swap shall be processes of this swap shall be
killed. One of killed. One of
<option>control-group</option>, <option>control-group</option>,
<option>process-group</option>,
<option>process</option>, <option>process</option>,
<option>none</option>.</para> <option>none</option>.</para>

View File

@ -1933,7 +1933,6 @@ DEFINE_STRING_TABLE_LOOKUP(exec_output, ExecOutput);
static const char* const kill_mode_table[_KILL_MODE_MAX] = { static const char* const kill_mode_table[_KILL_MODE_MAX] = {
[KILL_CONTROL_GROUP] = "control-group", [KILL_CONTROL_GROUP] = "control-group",
[KILL_PROCESS_GROUP] = "process-group",
[KILL_PROCESS] = "process", [KILL_PROCESS] = "process",
[KILL_NONE] = "none" [KILL_NONE] = "none"
}; };

View File

@ -43,7 +43,6 @@ struct CGroupBonding;
typedef enum KillMode { typedef enum KillMode {
KILL_CONTROL_GROUP = 0, KILL_CONTROL_GROUP = 0,
KILL_PROCESS_GROUP,
KILL_PROCESS, KILL_PROCESS,
KILL_NONE, KILL_NONE,
_KILL_MODE_MAX, _KILL_MODE_MAX,

View File

@ -747,9 +747,7 @@ static void mount_enter_signal(Mount *m, MountState state, bool success) {
state == MOUNT_REMOUNTING_SIGTERM) ? m->exec_context.kill_signal : SIGKILL; state == MOUNT_REMOUNTING_SIGTERM) ? m->exec_context.kill_signal : SIGKILL;
if (m->control_pid > 0) { if (m->control_pid > 0) {
if (kill_and_sigcont(m->exec_context.kill_mode == KILL_PROCESS_GROUP ? if (kill_and_sigcont(m->control_pid, sig) < 0 && errno != ESRCH)
-m->control_pid :
m->control_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill control process %li: %m", (long) m->control_pid); log_warning("Failed to kill control process %li: %m", (long) m->control_pid);
else else
@ -1684,7 +1682,7 @@ static int mount_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
} }
if (m->control_pid > 0) if (m->control_pid > 0)
if (kill(mode == KILL_PROCESS_GROUP ? -m->control_pid : m->control_pid, signo) < 0) if (kill(m->control_pid, signo) < 0)
r = -errno; r = -errno;
if (mode == KILL_CONTROL_GROUP) { if (mode == KILL_CONTROL_GROUP) {

View File

@ -828,7 +828,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
s->exec_context.std_output = s->exec_context.std_output =
(s->meta.manager->sysv_console || s->exec_context.std_input == EXEC_INPUT_TTY) (s->meta.manager->sysv_console || s->exec_context.std_input == EXEC_INPUT_TTY)
? EXEC_OUTPUT_TTY : s->meta.manager->default_std_output; ? EXEC_OUTPUT_TTY : s->meta.manager->default_std_output;
s->exec_context.kill_mode = KILL_PROCESS_GROUP; s->exec_context.kill_mode = KILL_PROCESS;
/* We use the long description only if /* We use the long description only if
* no short description is set. */ * no short description is set. */
@ -1838,19 +1838,14 @@ static void service_enter_signal(Service *s, ServiceState state, bool success) {
int sig = (state == SERVICE_STOP_SIGTERM || state == SERVICE_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL; int sig = (state == SERVICE_STOP_SIGTERM || state == SERVICE_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
if (s->main_pid > 0) { if (s->main_pid > 0) {
if (kill_and_sigcont(s->exec_context.kill_mode == KILL_PROCESS_GROUP ? if (kill_and_sigcont(s->main_pid, sig) < 0 && errno != ESRCH)
-s->main_pid :
s->main_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill main process %li: %m", (long) s->main_pid); log_warning("Failed to kill main process %li: %m", (long) s->main_pid);
else else
wait_for_exit = true; wait_for_exit = true;
} }
if (s->control_pid > 0) { if (s->control_pid > 0) {
if (kill_and_sigcont(s->exec_context.kill_mode == KILL_PROCESS_GROUP ? if (kill_and_sigcont(s->control_pid, sig) < 0 && errno != ESRCH)
-s->control_pid :
s->control_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill control process %li: %m", (long) s->control_pid); log_warning("Failed to kill control process %li: %m", (long) s->control_pid);
else else
@ -3212,11 +3207,11 @@ static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
} }
if (s->control_pid > 0) if (s->control_pid > 0)
if (kill(mode == KILL_PROCESS_GROUP ? -s->control_pid : s->control_pid, signo) < 0) if (kill(s->control_pid, signo) < 0)
r = -errno; r = -errno;
if (s->main_pid > 0) if (s->main_pid > 0)
if (kill(mode == KILL_PROCESS_GROUP ? -s->main_pid : s->main_pid, signo) < 0) if (kill(s->main_pid, signo) < 0)
r = -errno; r = -errno;
if (mode == KILL_CONTROL_GROUP) { if (mode == KILL_CONTROL_GROUP) {

View File

@ -1040,9 +1040,7 @@ static void socket_enter_signal(Socket *s, SocketState state, bool success) {
int sig = (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL; int sig = (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
if (s->control_pid > 0) { if (s->control_pid > 0) {
if (kill_and_sigcont(s->exec_context.kill_mode == KILL_PROCESS_GROUP ? if (kill_and_sigcont(s->control_pid, sig) < 0 && errno != ESRCH)
-s->control_pid :
s->control_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill control process %li: %m", (long) s->control_pid); log_warning("Failed to kill control process %li: %m", (long) s->control_pid);
else else
@ -1837,7 +1835,7 @@ static int socket_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError
} }
if (s->control_pid > 0) if (s->control_pid > 0)
if (kill(mode == KILL_PROCESS_GROUP ? -s->control_pid : s->control_pid, signo) < 0) if (kill(s->control_pid, signo) < 0)
r = -errno; r = -errno;
if (mode == KILL_CONTROL_GROUP) { if (mode == KILL_CONTROL_GROUP) {

View File

@ -661,9 +661,7 @@ static void swap_enter_signal(Swap *s, SwapState state, bool success) {
state == SWAP_DEACTIVATING_SIGTERM) ? s->exec_context.kill_signal : SIGKILL; state == SWAP_DEACTIVATING_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
if (s->control_pid > 0) { if (s->control_pid > 0) {
if (kill_and_sigcont(s->exec_context.kill_mode == KILL_PROCESS_GROUP ? if (kill_and_sigcont(s->control_pid, sig) < 0 && errno != ESRCH)
-s->control_pid :
s->control_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill control process %li: %m", (long) s->control_pid); log_warning("Failed to kill control process %li: %m", (long) s->control_pid);
else else
@ -1286,7 +1284,7 @@ static int swap_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusError *
} }
if (s->control_pid > 0) if (s->control_pid > 0)
if (kill(mode == KILL_PROCESS_GROUP ? -s->control_pid : s->control_pid, signo) < 0) if (kill(s->control_pid, signo) < 0)
r = -errno; r = -errno;
if (mode == KILL_CONTROL_GROUP) { if (mode == KILL_CONTROL_GROUP) {

View File

@ -60,7 +60,7 @@ _systemctl () {
comps='all control main' comps='all control main'
;; ;;
--kill-mode) --kill-mode)
comps='control-group process process-group' comps='control-group process'
;; ;;
--property|-p) --property|-p)
comps='' comps=''

View File

@ -31,7 +31,7 @@ WorkingDirectory=/root
ExecStart=-/sbin/sulogin ExecStart=-/sbin/sulogin
ExecStopPost=-/bin/systemctl poweroff ExecStopPost=-/bin/systemctl poweroff
StandardInput=tty-force StandardInput=tty-force
KillMode=process-group KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly. # terminates cleanly.

View File

@ -21,7 +21,7 @@ ExecStartPre=-/bin/echo 'Welcome to emergency mode. Use "systemctl default" or ^
ExecStart=-/sbin/sulogin ExecStart=-/sbin/sulogin
ExecStopPost=/bin/systemctl --fail default ExecStopPost=/bin/systemctl --fail default
StandardInput=tty-force StandardInput=tty-force
KillMode=process-group KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly. # terminates cleanly.

View File

@ -36,7 +36,7 @@ ExecStart=-/sbin/agetty %I 38400
Restart=always Restart=always
RestartSec=0 RestartSec=0
UtmpIdentifier=%I UtmpIdentifier=%I
KillMode=process-group KillMode=process
# Unset locale for the console getty since the console has problems # Unset locale for the console getty since the console has problems
# displaying some internationalized messages. # displaying some internationalized messages.

View File

@ -28,7 +28,7 @@ ExecStart=-/bin/bash -c "exec ${SINGLE}"',
`ExecStart=-/sbin/sulogin')) `ExecStart=-/sbin/sulogin'))
ExecStopPost=-/bin/systemctl --fail default ExecStopPost=-/bin/systemctl --fail default
StandardInput=tty-force StandardInput=tty-force
KillMode=process-group KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly. # terminates cleanly.

View File

@ -36,7 +36,7 @@ ExecStart=-/sbin/agetty -s %I 115200,38400,9600
Restart=always Restart=always
RestartSec=0 RestartSec=0
UtmpIdentifier=%I UtmpIdentifier=%I
KillMode=process-group KillMode=process
# Some login implementations ignore SIGTERM, so we send SIGHUP # Some login implementations ignore SIGTERM, so we send SIGHUP
# instead, to ensure that login terminates cleanly. # instead, to ensure that login terminates cleanly.