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

Method cleanup

test_infra/src/lib.rs:101–123  ·  view source on GitHub ↗

Kill all processes in the group for `test_name` and remove the entry.

(test_name: &str)

Source from the content-addressed store, hash-verified

99 /// Kill all processes in the group for `test_name` and remove
100 /// the entry.
101 pub fn cleanup(test_name: &str) -> bool {
102 let pgid = PROCESS_REGISTRY.lock().unwrap().remove(test_name);
103
104 if let Some(pgid) = pgid {
105 let ret = unsafe { libc::killpg(pgid as i32, libc::SIGKILL) };
106 if ret == 0 {
107 eprintln!(
108 "[cleanup] Sent SIGKILL to process group {pgid} \
109 (test '{test_name}')"
110 );
111 return true;
112 }
113 let err = io::Error::last_os_error();
114 // ESRCH: all processes already exited.
115 if err.raw_os_error() != Some(libc::ESRCH) {
116 eprintln!(
117 "[cleanup] Failed to kill process group {pgid} \
118 (test '{test_name}'): {err}"
119 );
120 }
121 }
122 false
123 }
124}
125
126#[derive(Error, Debug)]

Callers

nothing calls this directly

Calls 1

removeMethod · 0.45

Tested by

no test coverage detected