Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
test(gpui): retry the Linux process-check spawn while the copied binary is busy
Richie McIlroy4eb2448f1465
diff --git a/apps/desktop-gpui/src/single_instance.rs b/apps/desktop-gpui/src/single_instance.rsindex 9ac2e4f9a..632315e48 100644--- a/apps/desktop-gpui/src/single_instance.rs+++ b/apps/desktop-gpui/src/single_instance.rs@@ -1281,10 +1281,21 @@ mod tests {std::fs::create_dir(&directory).unwrap();let binary = directory.join("cap-gpui");std::fs::copy("/bin/sleep", &binary).unwrap();- let mut child = std::process::Command::new(&binary)- .arg("30")- .spawn()- .unwrap();+ // A test thread that forks while the copy's write descriptor is open+ // holds it until its exec, and exec of the copy fails with ETXTBSY+ // until then.+ let started = std::time::Instant::now();+ let mut child = loop {+ match std::process::Command::new(&binary).arg("30").spawn() {+ Err(error)+ if error.kind() == std::io::ErrorKind::ExecutableFileBusy+ && started.elapsed() < std::time::Duration::from_secs(5) =>+ {+ std::thread::sleep(std::time::Duration::from_millis(5));+ }+ result => break result.unwrap(),+ }+ };let pid = child.id() as i32;let started = std::time::Instant::now();// spawn can return before /proc stops exposing the child's pre-exec image.