Prevent Unix PTY I/O from blocking runtime shutdown (#40460)

## Why

Blocking PTY reads and output-channel sends can keep Tokio runtime shutdown
waiting when a detached child retains the terminal or output backpressure fills
the channel.

## What changed

- Drive Unix PTY reads and writes through nonblocking `AsyncFd` readiness so
  their tasks can be cancelled during shutdown.
- Keep draining child output after its receiver closes, and preserve queued
  input plus EOF delivery when portable PTY stdin closes.
- Return a descriptive error when PTY spawning uses a Tokio runtime without an
  I/O driver.

## Testing

Add Unix coverage for detached children, full and dropped output channels,
large input with EOF, inherited file descriptors, and runtimes without I/O.

GitOrigin-RevId: f7f1f58abebf8bf1d39285cd61b8d69946d54155
This commit is contained in:
viyatb-oai authored and copyberry committed 2026-08-24 19:25:32 +00:00
1 parent 4aa52f2cb2
commit bf3eb2ec91
5 files changed
+477 -65

No files matched your search

+2
View File
@@ -4,6 +4,8 @@ pub mod process_group;
pub mod pty;
#[cfg(test)]
mod tests;
#[cfg(unix)]
mod unix_io;
#[cfg(windows)]
mod win;
#[cfg(windows)]