From 73e0a6a456a765ae33bf4b25bec5965bfca1d00e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Tue, 6 Oct 2026 11:41:09 -0400 Subject: [PATCH] Test: retry the GPU startup sentinel check while a forked child briefly shares the lock monitor_profile tests spawn osascript in the same binary; between fork and exec the child holds a copy of the marker file descriptor, so flock reports WouldBlock and begin() returns Busy. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft/src/gpu_startup.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/photocraft/src/gpu_startup.rs b/apps/photocraft/src/gpu_startup.rs index 1f4af46bfe..d84744deaa 100644 --- a/apps/photocraft/src/gpu_startup.rs +++ b/apps/photocraft/src/gpu_startup.rs @@ -513,7 +513,16 @@ mod tests { assert!(none.is_none()); // The process dies in the driver: the lock goes, the marker stays. drop(s); - let (prev, s) = Sentinel::begin(&dir); + // Another test in this binary spawns a process: between its fork and exec the child briefly + // shares this file's flock, so `begin` can see the lock as busy. Retry for a moment. + let (mut prev, mut s) = Sentinel::begin(&dir); + for _ in 0..50 { + if prev != Previous::Busy { + break; + } + std::thread::sleep(std::time::Duration::from_millis(10)); + (prev, s) = Sentinel::begin(&dir); + } let m = prev.crashed().cloned().expect("crash detected"); assert_eq!((m.adapter.as_str(), m.tried()), ("GPU", Some(Vulkan))); // This start succeeds: the next one finds nothing.