chiark / gitweb /
journald: log provenience of signals
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Feb 2014 01:08:55 +0000 (20:08 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 12 Feb 2014 00:14:47 +0000 (19:14 -0500)
src/core/job.c
src/core/manager.c
src/journal/journald-server.c
src/shared/log.c
src/shared/log.h

index 941f9560258518f493f71c73c896947d1a22ea47..feeb563177e39351d1e05f512cde70403151797c 100644 (file)
@@ -1118,9 +1118,6 @@ int job_get_timeout(Job *j, uint64_t *timeout) {
 
         *timeout = MIN(x, y);
 
-        log_info("job_get_timeout %s %d/%"PRIu64" %d/%"PRIu64" -> 1/%"PRIu64,
-                 j->unit->id, r, x, q, y, *timeout);
-
         return 1;
 }
 
index f7e5cbdcf3c85608ecf7429ee0787991d1da3588..388697cdf57e40060d12d4f55750f37483f18596 100644 (file)
@@ -1532,23 +1532,10 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                         return -errno;
                 }
 
-                if (sfsi.ssi_pid > 0) {
-                        _cleanup_free_ char *p = NULL;
-
-                        get_process_comm(sfsi.ssi_pid, &p);
-
-                        log_full(sfsi.ssi_signo == SIGCHLD ||
-                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
-                                 ? LOG_DEBUG : LOG_INFO,
-                                 "Received SIG%s from PID "PID_FMT" (%s).",
-                                 signal_to_string(sfsi.ssi_signo),
-                                 sfsi.ssi_pid, strna(p));
-                } else
-                        log_full(sfsi.ssi_signo == SIGCHLD ||
-                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
-                                 ? LOG_DEBUG : LOG_INFO,
-                                 "Received SIG%s.",
-                                 signal_to_string(sfsi.ssi_signo));
+                log_received_signal(sfsi.ssi_signo == SIGCHLD ||
+                                    (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+                                    ? LOG_DEBUG : LOG_INFO,
+                                    &sfsi);
 
                 switch (sfsi.ssi_signo) {
 
index d3a1c574bd6d3ed3aa3273ed92c8e7a3a2a6f5f0..9ca3859297836e7e4eb8bdbbf4dce79bd2abd501 100644 (file)
@@ -1251,7 +1251,7 @@ static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *
 
         assert(s);
 
-        log_info("Received SIG%s", signal_to_string(si->ssi_signo));
+        log_received_signal(LOG_INFO, si);
 
         sd_event_exit(s->event, 0);
         return 0;
index 2a075ffebab7953c81c905b6811fb719ed80bb44..ee20921f7843845e3479a04cb2400b43f8f1cc5b 100644 (file)
@@ -973,3 +973,20 @@ static const char *const log_target_table[] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP(log_target, LogTarget);
+
+void log_received_signal(int level, const struct signalfd_siginfo *si) {
+        if (si->ssi_pid > 0) {
+                _cleanup_free_ char *p = NULL;
+
+                get_process_comm(si->ssi_pid, &p);
+
+                log_full(level,
+                         "Received SIG%s from PID "PID_FMT" (%s).",
+                         signal_to_string(si->ssi_signo),
+                         si->ssi_pid, strna(p));
+        } else
+                log_full(level,
+                         "Received SIG%s.",
+                         signal_to_string(si->ssi_signo));
+
+}
index 3dcfa113085b419a9bac1bbeade37e9acfdcdc54..6a0f6735c5a2e6f0151af764d5f8a65937d45ed1 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <syslog.h>
 #include <stdbool.h>
 #include <stdarg.h>
+#include <syslog.h>
+#include <sys/signalfd.h>
 #include <errno.h>
 
 #include "macro.h"
@@ -167,3 +168,5 @@ const char *log_target_to_string(LogTarget target) _const_;
 LogTarget log_target_from_string(const char *s) _pure_;
 
 #define MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
+
+void log_received_signal(int level, const struct signalfd_siginfo *si);