diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dbus-execute.c | 1 | ||||
-rw-r--r-- | src/dbus-execute.h | 3 | ||||
-rw-r--r-- | src/execute.c | 14 | ||||
-rw-r--r-- | src/execute.h | 2 | ||||
-rw-r--r-- | src/load-fragment-gperf.gperf.m4 | 1 | ||||
-rw-r--r-- | src/service.c | 1 |
6 files changed, 17 insertions, 5 deletions
diff --git a/src/dbus-execute.c b/src/dbus-execute.c index c5abcf674a..1fd2b21336 100644 --- a/src/dbus-execute.c +++ b/src/dbus-execute.c @@ -417,5 +417,6 @@ const BusProperty bus_exec_context_properties[] = { { "UtmpIdentifier", bus_property_append_string, "s", offsetof(ExecContext, utmp_id), true }, { "ControlGroupModify", bus_property_append_bool, "b", offsetof(ExecContext, control_group_modify) }, { "ControlGroupPersistent", bus_property_append_tristate_false, "b", offsetof(ExecContext, control_group_persistent) }, + { "IgnoreSIGPIPE", bus_property_append_bool, "b", offsetof(ExecContext, ignore_sigpipe ) }, { NULL, } }; diff --git a/src/dbus-execute.h b/src/dbus-execute.h index 0aea99e333..03cd69d126 100644 --- a/src/dbus-execute.h +++ b/src/dbus-execute.h @@ -95,7 +95,8 @@ " <property name=\"UtmpIdentifier\" type=\"s\" access=\"read\"/>\n" \ " <property name=\"ControlGroupModify\" 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) \ " <property name=\"" name "\" type=\"a(sasbttuii)\" access=\"read\"/>\n" diff --git a/src/execute.c b/src/execute.c index 536877d68c..dab485682b 100644 --- a/src/execute.c +++ b/src/execute.c @@ -1038,8 +1038,11 @@ int exec_spawn(ExecCommand *command, default_signals(SIGNALS_CRASH_HANDLER, SIGNALS_IGNORE, -1); - if (sigemptyset(&ss) < 0 || - sigprocmask(SIG_SETMASK, &ss, NULL) < 0) { + if (context->ignore_sigpipe) + ignore_signals(SIGPIPE, -1); + + assert_se(sigemptyset(&ss) == 0); + if (sigprocmask(SIG_SETMASK, &ss, NULL) < 0) { err = -errno; r = EXIT_SIGNAL_MASK; goto fail_child; @@ -1528,6 +1531,7 @@ void exec_context_init(ExecContext *c) { c->kill_signal = SIGTERM; c->send_sigkill = true; c->control_group_persistent = -1; + c->ignore_sigpipe = true; } void exec_context_done(ExecContext *c) { @@ -1876,10 +1880,12 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { fprintf(f, "%sKillMode: %s\n" "%sKillSignal: SIG%s\n" - "%sSendSIGKILL: %s\n", + "%sSendSIGKILL: %s\n" + "%sIgnoreSIGPIPE: %s\n", prefix, kill_mode_to_string(c->kill_mode), 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) fprintf(f, diff --git a/src/execute.h b/src/execute.h index ed90c6e3ed..0d7e7dd65d 100644 --- a/src/execute.h +++ b/src/execute.h @@ -128,6 +128,8 @@ struct ExecContext { bool tty_vhangup; bool tty_vt_disallocate; + bool ignore_sigpipe; + /* Since resolving these names might might involve socket * connections and we don't want to deadlock ourselves these * names are resolved on execution only and in the child diff --git a/src/load-fragment-gperf.gperf.m4 b/src/load-fragment-gperf.gperf.m4 index 9191f90642..9708ff8283 100644 --- a/src/load-fragment-gperf.gperf.m4 +++ b/src/load-fragment-gperf.gperf.m4 @@ -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.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.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.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)' diff --git a/src/service.c b/src/service.c index a190a73b48..9ccb1b6bc1 100644 --- a/src/service.c +++ b/src/service.c @@ -894,6 +894,7 @@ static int service_load_sysv_path(Service *s, const char *path) { s->remain_after_exit = !s->pid_file; s->guess_main_pid = false; s->restart = SERVICE_RESTART_NO; + s->exec_context.ignore_sigpipe = false; if (UNIT(s)->manager->sysv_console) s->exec_context.std_output = EXEC_OUTPUT_JOURNAL_AND_CONSOLE; |