commit da9af49ed74d64ca3f419493976cda1eb15c9773
parent f2070a71dc379e335ee26dba29c2143951615f11
Author: triesap <tyson@radroots.org>
Date: Fri, 17 Jul 2026 22:50:32 +0000
test: remove external helper PID race
- retry reads while the helper PID file is still empty
- retain the existing bounded synchronization deadline
- surface malformed PID contents after the deadline
- cover the timeout path with repeated real-process tests
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/custody.rs b/src/custody.rs
@@ -2308,7 +2308,13 @@ mod tests {
let pid_deadline = Instant::now() + timeout + Duration::from_secs(5);
let pid = loop {
match fs::read_to_string(&pid_path) {
- Ok(value) => break value.trim().parse::<u32>().expect("pid"),
+ Ok(value) => match value.trim().parse::<u32>() {
+ Ok(pid) => break pid,
+ Err(_) if Instant::now() < pid_deadline => {
+ std::thread::sleep(Duration::from_millis(10));
+ }
+ Err(error) => panic!("helper pid: {error}"),
+ },
Err(error)
if error.kind() == std::io::ErrorKind::NotFound
&& Instant::now() < pid_deadline =>