From 01417e69340695eff9d15c25dd7e306733f47d79 Mon Sep 17 00:00:00 2001 From: Johannes Leupolz Date: Wed, 17 Dec 2025 21:30:33 +0000 Subject: [PATCH] When integration-test get SIGKILLed, also SIGKILL the vuinputd-process --- vuinputd-tests/src/run_vuinputd.rs | 38 +++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/vuinputd-tests/src/run_vuinputd.rs b/vuinputd-tests/src/run_vuinputd.rs index be2ea99..e5241f4 100644 --- a/vuinputd-tests/src/run_vuinputd.rs +++ b/vuinputd-tests/src/run_vuinputd.rs @@ -3,22 +3,21 @@ // Author: Johannes Leupolz use std::{ + os::unix::process::CommandExt, process::{Child, Command}, sync::OnceLock, - time::Duration, thread, + time::Duration, }; -use nix::sys::signal::{self,Signal}; +use nix::sys::signal::{self, Signal}; use nix::unistd::Pid; /// Global singleton static VUINPUTD: OnceLock = OnceLock::new(); pub fn ensure_vuinputd_running() { - VUINPUTD.get_or_init(|| { - VuinputdGuard::start() - }); + VUINPUTD.get_or_init(|| VuinputdGuard::start()); } struct VuinputdGuard { @@ -28,14 +27,31 @@ struct VuinputdGuard { impl VuinputdGuard { fn start() -> Self { println!("Executing vuinputd located via cargo run"); - let child = Command::new("cargo") - .args(["run", "-p", "vuinputd", "--","--major","120","--minor","414796","--devname","vuinputd-test"]) - // adjust args/env if needed - .spawn() - .expect("failed to start vuinputd"); + let child = unsafe { + Command::new("cargo") + .args([ + "run", + "-p", + "vuinputd", + "--", + "--major", + "120", + "--minor", + "414796", + "--devname", + "vuinputd-test", + ]) + .pre_exec(|| { + // Last resort, if the parent just is killed. + libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGKILL); + Ok(()) + }) + .spawn() + .expect("failed to start vuinputd") + }; // Optional: give it time to create /dev/vuinput - thread::sleep(Duration::from_millis(300)); + thread::sleep(Duration::from_millis(1000)); Self { child } }