(pid: i32, target: &Path)
| 515 | /// `" (deleted)"` suffix on unlinked executables. |
| 516 | #[cfg(target_os = "linux")] |
| 517 | fn wait_for_child_exec(pid: i32, target: &Path) { |
| 518 | use std::os::unix::ffi::OsStrExt as _; |
| 519 | let target_bytes = target.as_os_str().as_bytes(); |
| 520 | let deadline = std::time::Instant::now() + std::time::Duration::from_secs(2); |
| 521 | loop { |
| 522 | if let Ok(link) = std::fs::read_link(format!("/proc/{pid}/exe")) |
| 523 | && link.as_os_str().as_bytes().starts_with(target_bytes) |
| 524 | { |
| 525 | return; |
| 526 | } |
| 527 | assert!( |
| 528 | std::time::Instant::now() < deadline, |
| 529 | "child pid {pid} did not exec into {target:?} within 2s" |
| 530 | ); |
| 531 | std::thread::sleep(std::time::Duration::from_millis(10)); |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | /// Retry `Command::spawn` on `ETXTBSY`. The kernel rejects `execve` when |
| 536 | /// `inode->i_writecount > 0`, and the release of that counter after the |
no outgoing calls