MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / kill_child

Function kill_child

test_infra/src/lib.rs:1100–1118  ·  view source on GitHub ↗
(child: &mut Child)

Source from the content-addressed store, hash-verified

1098}
1099
1100pub fn kill_child(child: &mut Child) {
1101 let r = unsafe { libc::kill(child.id() as i32, libc::SIGTERM) };
1102 if r != 0 {
1103 let e = io::Error::last_os_error();
1104 if e.raw_os_error().unwrap() == libc::ESRCH {
1105 return;
1106 }
1107 eprintln!("Failed to kill child with SIGTERM: {e:?}");
1108 }
1109
1110 // The timeout period elapsed without the child exiting
1111 if child.wait_timeout(Duration::new(10, 0)).unwrap().is_none() {
1112 let _ = child.kill();
1113 let rust_flags = env::var("RUSTFLAGS").unwrap_or_default();
1114 if rust_flags.contains("-Cinstrument-coverage") {
1115 panic!("Wait child timeout, please check the reason.")
1116 }
1117 }
1118}
1119
1120#[derive(Debug)]
1121pub struct MetaEvent {

Calls 4

newFunction · 0.85
killMethod · 0.80
containsMethod · 0.80
idMethod · 0.45