|
|
836b22 |
From f657f0399f5fa6ba45dbc6bc46be6d869f907409 Mon Sep 17 00:00:00 2001
|
|
|
836b22 |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
836b22 |
Date: Wed, 6 May 2020 21:38:12 +0200
|
|
|
836b22 |
Subject: [PATCH 25/25] WATCHDOG: log process termination to the journal
|
|
|
836b22 |
MIME-Version: 1.0
|
|
|
836b22 |
Content-Type: text/plain; charset=UTF-8
|
|
|
836b22 |
Content-Transfer-Encoding: 8bit
|
|
|
836b22 |
|
|
|
836b22 |
This patch adds explicit system journal message in case process was
|
|
|
836b22 |
terminated by an internal watchdog.
|
|
|
836b22 |
|
|
|
836b22 |
Resolves: https://github.com/SSSD/sssd/issues/5146
|
|
|
836b22 |
|
|
|
836b22 |
Reviewed-by: Pawel Polawski <ppolawsk@redhat.com>
|
|
|
836b22 |
(cherry picked from commit 65369f293b06ce0fe5622502bb32596bb50c523a)
|
|
|
836b22 |
|
|
|
836b22 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
836b22 |
|
|
|
836b22 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
836b22 |
---
|
|
|
836b22 |
src/monitor/monitor.c | 29 +++++++++++++++++++++++------
|
|
|
836b22 |
src/util/util.h | 2 ++
|
|
|
836b22 |
src/util/util_watchdog.c | 2 +-
|
|
|
836b22 |
3 files changed, 26 insertions(+), 7 deletions(-)
|
|
|
836b22 |
|
|
|
836b22 |
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
|
|
|
836b22 |
index ed40a920c..12250a15e 100644
|
|
|
836b22 |
--- a/src/monitor/monitor.c
|
|
|
836b22 |
+++ b/src/monitor/monitor.c
|
|
|
836b22 |
@@ -476,17 +476,34 @@ static int add_svc_conn_spy(struct mt_svc *svc)
|
|
|
836b22 |
|
|
|
836b22 |
static void svc_child_info(struct mt_svc *svc, int wait_status)
|
|
|
836b22 |
{
|
|
|
836b22 |
+ int exit_code = 0;
|
|
|
836b22 |
+ int pid = svc->pid;
|
|
|
836b22 |
+ const char *name = (svc->name ? svc->name : "");
|
|
|
836b22 |
+ const char *identity = (svc->identity ? svc->identity : "");
|
|
|
836b22 |
+
|
|
|
836b22 |
if (WIFEXITED(wait_status)) {
|
|
|
836b22 |
- DEBUG(SSSDBG_OP_FAILURE,
|
|
|
836b22 |
- "Child [%d] exited with code [%d]\n",
|
|
|
836b22 |
- svc->pid, WEXITSTATUS(wait_status));
|
|
|
836b22 |
+ exit_code = WEXITSTATUS(wait_status);
|
|
|
836b22 |
+ if (exit_code == SSS_WATCHDOG_EXIT_CODE) {
|
|
|
836b22 |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
836b22 |
+ "Child [%d] ('%s':'%s') was terminated by own WATCHDOG\n",
|
|
|
836b22 |
+ pid, name, identity);
|
|
|
836b22 |
+ sss_log(SSS_LOG_CRIT,
|
|
|
836b22 |
+ "Child [%d] ('%s':'%s') was terminated by own WATCHDOG. "
|
|
|
836b22 |
+ "Consult corresponding logs to figure out the reason.",
|
|
|
836b22 |
+ pid, name, identity);
|
|
|
836b22 |
+ } else {
|
|
|
836b22 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
836b22 |
+ "Child [%d] ('%s':'%s') exited with code [%d]\n",
|
|
|
836b22 |
+ pid, name, identity, exit_code);
|
|
|
836b22 |
+ }
|
|
|
836b22 |
} else if (WIFSIGNALED(wait_status)) {
|
|
|
836b22 |
DEBUG(SSSDBG_OP_FAILURE,
|
|
|
836b22 |
- "Child [%d] terminated with signal [%d]\n",
|
|
|
836b22 |
- svc->pid, WTERMSIG(wait_status));
|
|
|
836b22 |
+ "Child [%d] ('%s':'%s') terminated with signal [%d]\n",
|
|
|
836b22 |
+ pid, name, identity, WTERMSIG(wait_status));
|
|
|
836b22 |
} else {
|
|
|
836b22 |
DEBUG(SSSDBG_FATAL_FAILURE,
|
|
|
836b22 |
- "Child [%d] did not exit cleanly\n", svc->pid);
|
|
|
836b22 |
+ "Child [%d] ('%s':'%s') did not exit cleanly\n",
|
|
|
836b22 |
+ pid, name, identity);
|
|
|
836b22 |
/* Forcibly kill this child, just in case */
|
|
|
836b22 |
kill(svc->pid, SIGKILL);
|
|
|
836b22 |
|
|
|
836b22 |
diff --git a/src/util/util.h b/src/util/util.h
|
|
|
836b22 |
index 8a754dbfd..8dc887cab 100644
|
|
|
836b22 |
--- a/src/util/util.h
|
|
|
836b22 |
+++ b/src/util/util.h
|
|
|
836b22 |
@@ -104,6 +104,8 @@ extern int dbus_activated;
|
|
|
836b22 |
#define FLAGS_GEN_CONF 0x0008
|
|
|
836b22 |
#define FLAGS_NO_WATCHDOG 0x0010
|
|
|
836b22 |
|
|
|
836b22 |
+#define SSS_WATCHDOG_EXIT_CODE 70 /* to match EX_SOFTWARE in sysexits.h */
|
|
|
836b22 |
+
|
|
|
836b22 |
#define PIPE_INIT { -1, -1 }
|
|
|
836b22 |
|
|
|
836b22 |
#define PIPE_FD_CLOSE(fd) do { \
|
|
|
836b22 |
diff --git a/src/util/util_watchdog.c b/src/util/util_watchdog.c
|
|
|
836b22 |
index 0a4d83505..69160fbdf 100644
|
|
|
836b22 |
--- a/src/util/util_watchdog.c
|
|
|
836b22 |
+++ b/src/util/util_watchdog.c
|
|
|
836b22 |
@@ -75,7 +75,7 @@ static void watchdog_handler(int sig)
|
|
|
836b22 |
if (getpid() == getpgrp()) {
|
|
|
836b22 |
kill(-getpgrp(), SIGTERM);
|
|
|
836b22 |
}
|
|
|
836b22 |
- _exit(1);
|
|
|
836b22 |
+ _exit(SSS_WATCHDOG_EXIT_CODE);
|
|
|
836b22 |
}
|
|
|
836b22 |
}
|
|
|
836b22 |
|
|
|
836b22 |
--
|
|
|
836b22 |
2.21.1
|
|
|
836b22 |
|