Shared procguard cleanup callback for both libkrun and QEMU paths. Only async-signal-safe calls: atomic loads and `kill(2)`.
()
| 626 | /// Shared procguard cleanup callback for both libkrun and QEMU paths. |
| 627 | /// Only async-signal-safe calls: atomic loads and `kill(2)`. |
| 628 | fn procguard_kill_children() { |
| 629 | let helper_pid = GVPROXY_PID.load(Ordering::Relaxed); |
| 630 | let child_pid = CHILD_PID.load(Ordering::Relaxed); |
| 631 | if helper_pid > 0 { |
| 632 | unsafe { |
| 633 | libc::kill(helper_pid, libc::SIGTERM); |
| 634 | } |
| 635 | } |
| 636 | if child_pid > 0 { |
| 637 | unsafe { |
| 638 | libc::kill(child_pid, libc::SIGTERM); |
| 639 | } |
| 640 | } |
| 641 | std::thread::sleep(Duration::from_millis(200)); |
| 642 | if helper_pid > 0 { |
| 643 | unsafe { |
| 644 | libc::kill(helper_pid, libc::SIGKILL); |
| 645 | } |
| 646 | } |
| 647 | if child_pid > 0 { |
| 648 | unsafe { |
| 649 | libc::kill(child_pid, libc::SIGKILL); |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | fn run_libkrun_vm(config: &VmLaunchConfig) -> Result<(), String> { |
| 655 | if let Some(kernel_image) = &config.kernel_image { |