summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/log.c17
-rw-r--r--src/shared/log.h5
2 files changed, 21 insertions, 1 deletions
diff --git a/src/shared/log.c b/src/shared/log.c
index 2a075ffeba..ee20921f78 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -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));
+
+}
diff --git a/src/shared/log.h b/src/shared/log.h
index 3dcfa11308..6a0f6735c5 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -21,9 +21,10 @@
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);