cli: add extra fs operations for container

Ref https://github.com/microsoft/vscode-remote-tunnels/issues/695
This commit is contained in:
Connor Peet
2023-10-18 19:08:19 -07:00
parent 96d5db84d1
commit 4aa04c7db2
3 changed files with 206 additions and 20 deletions

View File

@@ -29,6 +29,18 @@ pub fn process_exists(pid: u32) -> bool {
sys.refresh_process(Pid::from_u32(pid))
}
pub fn kill_pid(pid: u32) -> bool {
let mut sys = System::new();
let pid = Pid::from_u32(pid);
sys.refresh_process(pid);
if let Some(p) = sys.process(pid) {
p.kill()
} else {
false
}
}
pub async fn wait_until_process_exits(pid: Pid, poll_ms: u64) {
let mut s = System::new();
let duration = Duration::from_millis(poll_ms);