From ae24c566d2af185f91f7b9679836d19251038015 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 2 Oct 2026 11:08:13 +0200 Subject: [PATCH] Fixed cf-agent assertion failure when reading /proc//stat GetProcessStat() asserted on unexpected open() errors, e.g. when the process exited in the meantime. Release builds would loop forever instead. Now logs the error and returns false. Co-Authored-By: Claude Opus 5.5 Ticket: CFE-4285 Changelog: Title Signed-off-by: Lars Erik Wik (cherry picked from commit 59bf3321a17c5a1362c0ee464423cdb6ca6bbbf2) --- libpromises/process_linux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libpromises/process_linux.c b/libpromises/process_linux.c index 5bd833b0085..19d6ce47145 100644 --- a/libpromises/process_linux.c +++ b/libpromises/process_linux.c @@ -63,7 +63,10 @@ static bool GetProcessStat(pid_t pid, ProcessStat *state) return false; } - assert (fd != -1 && "Unable to open /proc//stat"); + /* E.g. the process may have exited in the meantime */ + Log(LOG_LEVEL_DEBUG, "Failed to open '%s' (open: %s)", + filename, GetErrorStr()); + return false; } char stat[CF_BUFSIZE];