Skip to content

Commit

Permalink
check process state while exec delete
Browse files Browse the repository at this point in the history
  • Loading branch information
mingfukuang committed Aug 3, 2024
1 parent 314702f commit 9d5a178
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/runc-shim/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

use std::env;
use tokio::runtime::Builder;

use containerd_shim::{asynchronous::run, parse};
use tokio::runtime::Builder;

mod cgroup_memory;
mod common;
Expand Down
3 changes: 3 additions & 0 deletions crates/runc-shim/src/runc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ impl ProcessLifecycle<ExecProcess> for RuncExecLifecycle {
}

async fn delete(&self, p: &mut ExecProcess) -> Result<()> {
if p.state == Status::RUNNING {
return Err(Error::Other("cannot delete a running process".to_string()));
}
self.exit_signal.signal();
let exec_pid_path = Path::new(self.bundle.as_str()).join(format!("{}.pid", p.id));
remove_file(exec_pid_path).await.unwrap_or_default();
Expand Down

0 comments on commit 9d5a178

Please sign in to comment.