1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Lock test helpers shared across integration tests.
//!
//! Purpose:
//! - Lock test helpers shared across integration tests.
//!
//! Responsibilities:
//! - Provide short-lived process utilities for lock-related tests.
//!
//! Not handled here:
//! - Lock acquisition logic or filesystem operations.
//! - Assertions about lock behavior.
//!
//!
//! Usage:
//! - Used through the crate module tree or integration test harness.
//!
//! Invariants/assumptions:
//! - Spawns the current test binary with `--help` and waits for exit.
//! - Returned PID should be treated as stale immediately after the process exits.
use std::path::PathBuf;
use std::process::{Command, Stdio};
pub fn spawn_exited_pid() -> u32 {
let mut child = Command::new(current_exe())
.arg("--help")
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.expect("spawn helper process");
let pid = child.id();
let _ = child.wait();
pid
}
fn current_exe() -> PathBuf {
std::env::current_exe().expect("resolve current test executable path")
}