builder: register the owned pidfd with the current Tokio API

This commit is contained in:
2026-11-07 14:46:04 +00:00
parent 7ee4059414
commit d63482f02e
+2 -1
View File
@@ -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??;