diff --git a/host/src/builder/tests.rs b/host/src/builder/tests.rs index cc27d26..c373593 100644 --- a/host/src/builder/tests.rs +++ b/host/src/builder/tests.rs @@ -203,7 +203,8 @@ async fn timeout_kills_before_output_can_drain() -> Result<()> { let pid: u32 = std::str::from_utf8(&bytes)?.trim().parse()?; let fd = unsafe { libc::syscall(libc::SYS_pidfd_open, pid, 0) }; ensure!(fd >= 0, "pidfd_open: {}", std::io::Error::last_os_error()); - let exited = tokio::io::unix::AsyncFd::new(unsafe { OwnedFd::from_raw_fd(fd as i32) })?; + // OwnedFd keeps the PID descriptor valid and unchanged until AsyncFd drops it. + let exited = unsafe { tokio::io::unix::AsyncFd::register(OwnedFd::from_raw_fd(fd as i32)) }?; // Fill the output channel, so the timeout message cannot enter it. tx.send(Event::Stdout { bytes: Vec::new() }).await?; let _ready = tokio::time::timeout(Duration::from_secs(2), exited.readable()).await??;