chiark / gitweb /
service: ignore SIGPIPE by default v41
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Feb 2012 02:18:04 +0000 (03:18 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 9 Feb 2012 02:18:04 +0000 (03:18 +0100)
14 files changed:
NEWS
TODO
man/systemd.exec.xml
src/dbus-execute.c
src/dbus-execute.h
src/execute.c
src/execute.h
src/load-fragment-gperf.gperf.m4
src/service.c
units/console-shell.service.m4
units/emergency.service
units/fedora/prefdm.service
units/getty@.service.m4
units/serial-getty@.service.m4

diff --git a/NEWS b/NEWS
index e95ac637ef47be0b668b4562f1ea976b3408da3c..7dcac85fecf8fb6cb5f469c759e580c184898d56 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,11 @@ CHANGES WITH 41:
 
        * 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
         Poettering, Michael Olbrich, Michal Schmidt, Tom Gundersen,
         William Douglas
diff --git a/TODO b/TODO
index 42d577ba79c4df1eebeaa30aa7ad85ea1d3d8c32..ed857f836b5426fbc44e2a30bd843d532cc289f5 100644 (file)
--- a/TODO
+++ b/TODO
@@ -21,6 +21,8 @@ Bugfixes:
 
 Features:
 
+* add interface to allow immediate rotation of the journal, and even flushing.
+
 * don't log coredumps of PID 1 into the journal
 
 * if a journal file is corrupt, rotate it and create a new one
index 8c363a069910fe68bc0730da4b568f369a8aa373..ac0f89fb85b2482f1216ea0f7492943918387bae 100644 (file)
                                 this service.</para></listitem>
                         </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>
         </refsect1>
 
index c5abcf674a73141828561f86e8afb4ce94ea7e74..1fd2b2133674f1cace4887fade645d16472085b7 100644 (file)
@@ -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, }
 };
index 0aea99e33356ed99a9bca1ba454463d82dc1708a..03cd69d12603be53978aa85ac08b66c1f16730cf 100644 (file)
@@ -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"
index 536877d68c2a8877e1346889100a61a622a26df9..dab485682b899daeac0bab8aeeb683a145e12dfc 100644 (file)
@@ -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,
index ed90c6e3edaf51a6c547997cd7546450c0a00a3a..0d7e7dd65db1feb8727c5d5137519da1644b5741 100644 (file)
@@ -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
index 9191f906421daa75b1f6dae60fbac7bbfbd20bd9..9708ff8283b3f62e7f9ebf430eed58de0be4ac4a 100644 (file)
@@ -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)'
index a190a73b483d1857d7d76408a1d0be1b2000e13d..9ccb1b6bc10318e9cb68c44d40cfeed9c0571aa4 100644 (file)
@@ -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;
index 02adc8403bce675aec336ec6a981c533f7bdb3d8..fef9e1b176265c9d7cca18ff406a836b6ea7b994 100644 (file)
@@ -37,6 +37,7 @@ StandardInput=tty-force
 StandardOutput=inherit
 StandardError=inherit
 KillMode=process
+IgnoreSIGPIPE=no
 
 # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
 # terminates cleanly.
index 4847f4f0c6ef243c878fa6e635cb8976911becf3..234bafcc88b1e69c70d4ad40aba23b12914a26ea 100644 (file)
@@ -24,6 +24,7 @@ StandardInput=tty-force
 StandardOutput=inherit
 StandardError=inherit
 KillMode=process
+IgnoreSIGPIPE=no
 
 # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
 # terminates cleanly.
index 17ed4cd7868ad511af472c1ad91560fca45be71f..77a0e9ad7cd2966bc1f3b24f37f977e4a6b912d3 100644 (file)
@@ -18,3 +18,4 @@ After=getty@tty1.service plymouth-quit.service
 ExecStart=/etc/X11/prefdm -nodaemon
 Restart=always
 RestartSec=0
+IgnoreSIGPIPE=no
index d2a145dacd433664885a6a4c210e0fa3d60b814e..a02838d7850181695cf4f7c287f27b4916a55df1 100644 (file)
@@ -44,6 +44,7 @@ TTYReset=yes
 TTYVHangup=yes
 TTYVTDisallocate=yes
 KillMode=process
+IgnoreSIGPIPE=no
 
 # Unset locale for the console getty since the console has problems
 # displaying some internationalized messages.
index e5f0ca6c6c0370a4b1a4e7203533e71d118495eb..fc8b57b93e8f96de073f55ef4ee7bd810c80a238 100644 (file)
@@ -43,6 +43,7 @@ TTYPath=/dev/%I
 TTYReset=yes
 TTYVHangup=yes
 KillMode=process
+IgnoreSIGPIPE=no
 
 # Some login implementations ignore SIGTERM, so we send SIGHUP
 # instead, to ensure that login terminates cleanly.