From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 1A0981FF17C for ; Wed, 25 Jun 2025 15:24:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E337915630; Wed, 25 Jun 2025 15:24:23 +0200 (CEST) From: Maximiliano Sandoval To: pve-devel@lists.proxmox.com Date: Wed, 25 Jun 2025 15:23:49 +0200 Message-Id: <20250625132349.385901-6-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250625132349.385901-1-m.sandoval@proxmox.com> References: <20250625132349.385901-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.099 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH ha-manager v2 5/5] watchdog-mux: sync journal right after fencing warning X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 --- src/watchdog-mux.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/watchdog-mux.c b/src/watchdog-mux.c index 2287625..93f9bd9 100644 --- a/src/watchdog-mux.c +++ b/src/watchdog-mux.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -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 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel