[pve-devel] [PATCH ha-manager v3 4/6] watchdog-mux: sync journal right after fence warning
Maximiliano Sandoval
m.sandoval at proxmox.com
Fri Jul 4 15:39:00 CEST 2025
Since this journal entry can be logged multiple times in the lifespan on
the process, we double fork to prevent accumulating zombie processes.
Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
src/watchdog-mux.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/watchdog-mux.c b/src/watchdog-mux.c
index 0518e86..11571ec 100644
--- a/src/watchdog-mux.c
+++ b/src/watchdog-mux.c
@@ -12,6 +12,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
+#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
@@ -116,6 +117,22 @@ static void sync_journal_unsafe(void) {
}
}
+// Like sync_journal_unsafe but we double fork so we don't leave trailing zombie
+// processes.
+static void sync_journal_in_fork(void) {
+ pid_t child = fork();
+ if (child == 0) {
+ child = fork();
+ if (child == 0) {
+ execl(JOURNALCTL_BIN, JOURNALCTL_BIN, "--sync", NULL);
+ exit(-1);
+ }
+ exit(0);
+ } else if (child > 0) {
+ wait(NULL);
+ }
+}
+
int main(void) {
struct sockaddr_un my_addr, peer_addr;
socklen_t peer_addr_size;
@@ -254,6 +271,7 @@ int main(void) {
(ctime - client_list[i].time) > CLIENT_WATCHDOG_TIMEOUT_WARNING) {
client_list[i].warning_state = WARNING_ISSUED;
fprintf(stderr, "client watchdog is about to expire\n");
+ sync_journal_in_fork ();
}
if ((ctime - client_list[i].time) > CLIENT_WATCHDOG_TIMEOUT) {
--
2.39.5
More information about the pve-devel
mailing list