From 213633478307d6178b5ce85b27350d63174651e7 Mon Sep 17 00:00:00 2001 From: licunlong Date: Wed, 5 Jul 2023 09:31:43 +0800 Subject: [PATCH] fix: log message before and after reaping zombie process --- core/sysmaster/unit/sigchld.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/sysmaster/unit/sigchld.rs b/core/sysmaster/unit/sigchld.rs index 72da0eb..423b9b9 100644 --- a/core/sysmaster/unit/sigchld.rs +++ b/core/sysmaster/unit/sigchld.rs @@ -197,7 +197,9 @@ impl SigchldData { } // check - let (pid, _code, _signal) = si.unwrap(); + let (pid, code, signal) = si.unwrap(); + log::debug!("Process {} exited witch code: {code}, signal: {signal:?}", pid.as_raw()); + if pid.as_raw() <= 0 { log::debug!("invalid pid in signal: {:?}", pid); return false; // turn_off @@ -214,8 +216,9 @@ impl SigchldData { } // pop: reap the zombie - if let Err(e) = wait::waitid(Id::Pid(pid), WaitPidFlag::WEXITED) { - log::error!("Error when reap the zombie, ignoring: {}", e); + match wait::waitid(Id::Pid(pid), WaitPidFlag::WEXITED) { + Err(e) => log::error!("Failed to reap process {}: {e}", pid.as_raw()), + Ok(_) => log::debug!("Reaped process {}", pid.as_raw()), } true // stay turn_on -- 2.33.0