From d63482f02e9011ee9df76720bbb76985543f7a7f Mon Sep 17 00:00:00 2001 From: Surma Date: Sat, 7 Nov 2026 14:46:04 +0000 Subject: [PATCH] builder: register the owned pidfd with the current Tokio API --- host/src/builder/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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??;