MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / terminate_vm_process

Function terminate_vm_process

crates/openshell-driver-vm/src/driver.rs:4960–4978  ·  view source on GitHub ↗
(child: &mut Child)

Source from the content-addressed store, hash-verified

4958}
4959
4960async fn terminate_vm_process(child: &mut Child) -> Result<(), std::io::Error> {
4961 if let Some(pid) = child.id()
4962 && let Err(err) = kill(Pid::from_raw(pid.cast_signed()), Signal::SIGTERM)
4963 && err != Errno::ESRCH
4964 {
4965 return Err(std::io::Error::other(format!(
4966 "send SIGTERM to vm process {pid}: {err}"
4967 )));
4968 }
4969
4970 match tokio::time::timeout(Duration::from_secs(5), child.wait()).await {
4971 Ok(Ok(_)) => Ok(()),
4972 Ok(Err(err)) => Err(err),
4973 Err(_) => {
4974 child.kill().await?;
4975 child.wait().await.map(|_| ())
4976 }
4977 }
4978}
4979
4980fn sandbox_snapshot(sandbox: &Sandbox, condition: SandboxCondition, deleting: bool) -> Sandbox {
4981 Sandbox {

Callers 2

delete_sandboxMethod · 0.85

Calls 3

waitMethod · 0.80
killMethod · 0.80
idMethod · 0.45

Tested by

no test coverage detected