From e5568a31a7f5d7fcbc8f0962ee7c5f2569c792d9 Mon Sep 17 00:00:00 2001 From: Feng Wang Date: Wed, 1 Jun 2022 17:38:28 -0700 Subject: [PATCH] agent: ignore ESRCH error when destroying containers destroy() method should ignore the ESRCH error from signal::kill and continue the operation as ESRCH is often considered harmless. Fixes: #4359 Signed-off-by: Feng Wang --- src/agent/rustjail/src/container.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/agent/rustjail/src/container.rs b/src/agent/rustjail/src/container.rs index c4cc8a095c..98b4245a9d 100644 --- a/src/agent/rustjail/src/container.rs +++ b/src/agent/rustjail/src/container.rs @@ -1032,7 +1032,19 @@ impl BaseContainer for LinuxContainer { let st = self.oci_state()?; for pid in self.processes.keys() { - signal::kill(Pid::from_raw(*pid), Some(Signal::SIGKILL))?; + match signal::kill(Pid::from_raw(*pid), Some(Signal::SIGKILL)) { + Err(Errno::ESRCH) => { + info!( + self.logger, + "kill encounters ESRCH, pid: {}, container: {}", + pid, + self.id.clone() + ); + continue; + } + Err(err) => return Err(anyhow!(err)), + Ok(_) => continue, + } } if spec.hooks.is_some() {