mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
service: ignore SIGPIPE by default
This commit is contained in:
parent
12ac304714
commit
353e12c2f4
5
NEWS
5
NEWS
@ -18,6 +18,11 @@ CHANGES WITH 41:
|
|||||||
|
|
||||||
* We now limit the set of capabilities of systemd-journald.
|
* We now limit the set of capabilities of systemd-journald.
|
||||||
|
|
||||||
|
* We now set SIGPIPE to ignore by default, since it only is
|
||||||
|
useful in shell pipelines, and has little use in general
|
||||||
|
code. This can be disabled with IgnoreSIPIPE=no in unit
|
||||||
|
files.
|
||||||
|
|
||||||
Contributions from: Benjamin Franzke, Kay Sievers, Lennart
|
Contributions from: Benjamin Franzke, Kay Sievers, Lennart
|
||||||
Poettering, Michael Olbrich, Michal Schmidt, Tom Gundersen,
|
Poettering, Michael Olbrich, Michal Schmidt, Tom Gundersen,
|
||||||
William Douglas
|
William Douglas
|
||||||
|
2
TODO
2
TODO
@ -21,6 +21,8 @@ Bugfixes:
|
|||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
|
* add interface to allow immediate rotation of the journal, and even flushing.
|
||||||
|
|
||||||
* don't log coredumps of PID 1 into the journal
|
* don't log coredumps of PID 1 into the journal
|
||||||
|
|
||||||
* if a journal file is corrupt, rotate it and create a new one
|
* if a journal file is corrupt, rotate it and create a new one
|
||||||
|
@ -1075,6 +1075,17 @@
|
|||||||
this service.</para></listitem>
|
this service.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>IgnoreSIGPIPE=</varname></term>
|
||||||
|
|
||||||
|
<listitem><para>Takes a boolean
|
||||||
|
argument. If true causes SIGPIPE to be
|
||||||
|
ignored in the executed
|
||||||
|
process. Defaults to true, since
|
||||||
|
SIGPIPE generally is useful only in
|
||||||
|
shell pipelines.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
@ -417,5 +417,6 @@ const BusProperty bus_exec_context_properties[] = {
|
|||||||
{ "UtmpIdentifier", bus_property_append_string, "s", offsetof(ExecContext, utmp_id), true },
|
{ "UtmpIdentifier", bus_property_append_string, "s", offsetof(ExecContext, utmp_id), true },
|
||||||
{ "ControlGroupModify", bus_property_append_bool, "b", offsetof(ExecContext, control_group_modify) },
|
{ "ControlGroupModify", bus_property_append_bool, "b", offsetof(ExecContext, control_group_modify) },
|
||||||
{ "ControlGroupPersistent", bus_property_append_tristate_false, "b", offsetof(ExecContext, control_group_persistent) },
|
{ "ControlGroupPersistent", bus_property_append_tristate_false, "b", offsetof(ExecContext, control_group_persistent) },
|
||||||
|
{ "IgnoreSIGPIPE", bus_property_append_bool, "b", offsetof(ExecContext, ignore_sigpipe ) },
|
||||||
{ NULL, }
|
{ NULL, }
|
||||||
};
|
};
|
||||||
|
@ -95,7 +95,8 @@
|
|||||||
" <property name=\"UtmpIdentifier\" type=\"s\" access=\"read\"/>\n" \
|
" <property name=\"UtmpIdentifier\" type=\"s\" access=\"read\"/>\n" \
|
||||||
" <property name=\"ControlGroupModify\" type=\"b\" access=\"read\"/>\n" \
|
" <property name=\"ControlGroupModify\" type=\"b\" access=\"read\"/>\n" \
|
||||||
" <property name=\"ControlGroupPersistent\" type=\"b\" access=\"read\"/>\n" \
|
" <property name=\"ControlGroupPersistent\" type=\"b\" access=\"read\"/>\n" \
|
||||||
" <property name=\"PrivateNetwork\" type=\"b\" access=\"read\"/>\n"
|
" <property name=\"PrivateNetwork\" type=\"b\" access=\"read\"/>\n" \
|
||||||
|
" <property name=\"IgnoreSIGPIPE\" type=\"b\" access=\"read\"/>\n"
|
||||||
|
|
||||||
#define BUS_EXEC_COMMAND_INTERFACE(name) \
|
#define BUS_EXEC_COMMAND_INTERFACE(name) \
|
||||||
" <property name=\"" name "\" type=\"a(sasbttuii)\" access=\"read\"/>\n"
|
" <property name=\"" name "\" type=\"a(sasbttuii)\" access=\"read\"/>\n"
|
||||||
|
@ -1038,8 +1038,11 @@ int exec_spawn(ExecCommand *command,
|
|||||||
default_signals(SIGNALS_CRASH_HANDLER,
|
default_signals(SIGNALS_CRASH_HANDLER,
|
||||||
SIGNALS_IGNORE, -1);
|
SIGNALS_IGNORE, -1);
|
||||||
|
|
||||||
if (sigemptyset(&ss) < 0 ||
|
if (context->ignore_sigpipe)
|
||||||
sigprocmask(SIG_SETMASK, &ss, NULL) < 0) {
|
ignore_signals(SIGPIPE, -1);
|
||||||
|
|
||||||
|
assert_se(sigemptyset(&ss) == 0);
|
||||||
|
if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0) {
|
||||||
err = -errno;
|
err = -errno;
|
||||||
r = EXIT_SIGNAL_MASK;
|
r = EXIT_SIGNAL_MASK;
|
||||||
goto fail_child;
|
goto fail_child;
|
||||||
@ -1528,6 +1531,7 @@ void exec_context_init(ExecContext *c) {
|
|||||||
c->kill_signal = SIGTERM;
|
c->kill_signal = SIGTERM;
|
||||||
c->send_sigkill = true;
|
c->send_sigkill = true;
|
||||||
c->control_group_persistent = -1;
|
c->control_group_persistent = -1;
|
||||||
|
c->ignore_sigpipe = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_context_done(ExecContext *c) {
|
void exec_context_done(ExecContext *c) {
|
||||||
@ -1876,10 +1880,12 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
|
|||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%sKillMode: %s\n"
|
"%sKillMode: %s\n"
|
||||||
"%sKillSignal: SIG%s\n"
|
"%sKillSignal: SIG%s\n"
|
||||||
"%sSendSIGKILL: %s\n",
|
"%sSendSIGKILL: %s\n"
|
||||||
|
"%sIgnoreSIGPIPE: %s\n",
|
||||||
prefix, kill_mode_to_string(c->kill_mode),
|
prefix, kill_mode_to_string(c->kill_mode),
|
||||||
prefix, signal_to_string(c->kill_signal),
|
prefix, signal_to_string(c->kill_signal),
|
||||||
prefix, yes_no(c->send_sigkill));
|
prefix, yes_no(c->send_sigkill),
|
||||||
|
prefix, yes_no(c->ignore_sigpipe));
|
||||||
|
|
||||||
if (c->utmp_id)
|
if (c->utmp_id)
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
|
@ -128,6 +128,8 @@ struct ExecContext {
|
|||||||
bool tty_vhangup;
|
bool tty_vhangup;
|
||||||
bool tty_vt_disallocate;
|
bool tty_vt_disallocate;
|
||||||
|
|
||||||
|
bool ignore_sigpipe;
|
||||||
|
|
||||||
/* Since resolving these names might might involve socket
|
/* Since resolving these names might might involve socket
|
||||||
* connections and we don't want to deadlock ourselves these
|
* connections and we don't want to deadlock ourselves these
|
||||||
* names are resolved on execution only and in the child
|
* names are resolved on execution only and in the child
|
||||||
|
@ -85,6 +85,7 @@ $1.PAMName, config_parse_unit_string_printf, 0,
|
|||||||
$1.KillMode, config_parse_kill_mode, 0, offsetof($1, exec_context.kill_mode)
|
$1.KillMode, config_parse_kill_mode, 0, offsetof($1, exec_context.kill_mode)
|
||||||
$1.KillSignal, config_parse_kill_signal, 0, offsetof($1, exec_context.kill_signal)
|
$1.KillSignal, config_parse_kill_signal, 0, offsetof($1, exec_context.kill_signal)
|
||||||
$1.SendSIGKILL, config_parse_bool, 0, offsetof($1, exec_context.send_sigkill)
|
$1.SendSIGKILL, config_parse_bool, 0, offsetof($1, exec_context.send_sigkill)
|
||||||
|
$1.IgnoreSIGPIPE, config_parse_bool, 0, offsetof($1, exec_context.ignore_sigpipe)
|
||||||
$1.UtmpIdentifier, config_parse_unit_string_printf, 0, offsetof($1, exec_context.utmp_id)
|
$1.UtmpIdentifier, config_parse_unit_string_printf, 0, offsetof($1, exec_context.utmp_id)
|
||||||
$1.ControlGroupModify, config_parse_bool, 0, offsetof($1, exec_context.control_group_modify)
|
$1.ControlGroupModify, config_parse_bool, 0, offsetof($1, exec_context.control_group_modify)
|
||||||
$1.ControlGroupPersistent, config_parse_tristate, 0, offsetof($1, exec_context.control_group_persistent)'
|
$1.ControlGroupPersistent, config_parse_tristate, 0, offsetof($1, exec_context.control_group_persistent)'
|
||||||
|
@ -894,6 +894,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
|
|||||||
s->remain_after_exit = !s->pid_file;
|
s->remain_after_exit = !s->pid_file;
|
||||||
s->guess_main_pid = false;
|
s->guess_main_pid = false;
|
||||||
s->restart = SERVICE_RESTART_NO;
|
s->restart = SERVICE_RESTART_NO;
|
||||||
|
s->exec_context.ignore_sigpipe = false;
|
||||||
|
|
||||||
if (UNIT(s)->manager->sysv_console)
|
if (UNIT(s)->manager->sysv_console)
|
||||||
s->exec_context.std_output = EXEC_OUTPUT_JOURNAL_AND_CONSOLE;
|
s->exec_context.std_output = EXEC_OUTPUT_JOURNAL_AND_CONSOLE;
|
||||||
|
@ -37,6 +37,7 @@ StandardInput=tty-force
|
|||||||
StandardOutput=inherit
|
StandardOutput=inherit
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
KillMode=process
|
KillMode=process
|
||||||
|
IgnoreSIGPIPE=no
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -24,6 +24,7 @@ StandardInput=tty-force
|
|||||||
StandardOutput=inherit
|
StandardOutput=inherit
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
KillMode=process
|
KillMode=process
|
||||||
|
IgnoreSIGPIPE=no
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -18,3 +18,4 @@ After=getty@tty1.service plymouth-quit.service
|
|||||||
ExecStart=/etc/X11/prefdm -nodaemon
|
ExecStart=/etc/X11/prefdm -nodaemon
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=0
|
RestartSec=0
|
||||||
|
IgnoreSIGPIPE=no
|
||||||
|
@ -44,6 +44,7 @@ TTYReset=yes
|
|||||||
TTYVHangup=yes
|
TTYVHangup=yes
|
||||||
TTYVTDisallocate=yes
|
TTYVTDisallocate=yes
|
||||||
KillMode=process
|
KillMode=process
|
||||||
|
IgnoreSIGPIPE=no
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -43,6 +43,7 @@ TTYPath=/dev/%I
|
|||||||
TTYReset=yes
|
TTYReset=yes
|
||||||
TTYVHangup=yes
|
TTYVHangup=yes
|
||||||
KillMode=process
|
KillMode=process
|
||||||
|
IgnoreSIGPIPE=no
|
||||||
|
|
||||||
# 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user