(child: &mut Child)
| 4958 | } |
| 4959 | |
| 4960 | async 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 | |
| 4980 | fn sandbox_snapshot(sandbox: &Sandbox, condition: SandboxCondition, deleting: bool) -> Sandbox { |
| 4981 | Sandbox { |
no test coverage detected