Skip to content

Commit

Permalink
Merge pull request #1339 from YJDoc2/kill_ignore_ESRCH
Browse files Browse the repository at this point in the history
Ignore error when killing, if error is 'process does not exist'
  • Loading branch information
utam0k authored Nov 14, 2022
2 parents 1d9624d + 2674f8a commit a25de6c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions crates/libcontainer/src/container/container_kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ impl Container {
let pid = self.pid().unwrap();

log::debug!("kill signal {} to {}", signal, pid);
signal::kill(pid, signal)?;
let res = signal::kill(pid, signal);

match res {
Err(nix::errno::Errno::ESRCH) => {
/* the process does not exist, which is what we want */
}
_ => res?,
}

// For cgroup V1, a frozon process cannot respond to signals,
// so we need to thaw it. Only thaw the cgroup for SIGKILL.
if self.status() == ContainerStatus::Paused && signal == signal::Signal::SIGKILL {
Expand Down Expand Up @@ -95,7 +103,14 @@ impl Container {
let pids = cmanger.get_all_pids()?;
pids.iter().try_for_each(|&pid| {
log::debug!("kill signal {} to {}", signal, pid);
signal::kill(pid, signal)
let res = signal::kill(pid, signal);
match res {
Err(nix::errno::Errno::ESRCH) => {
/* the process does not exist, which is what we want */
Ok(())
}
_ => res,
}
})?;
let ret = cmanger.freeze(libcgroups::common::FreezerState::Thawed);
if ret.is_err() {
Expand Down

0 comments on commit a25de6c

Please sign in to comment.