Preserve child waiters during process termination (#37498)

## Why

Aborting the child waiter during termination can leave an exited PTY child
unreaped and prevent the session from recording its exit status.

## What changed

- Detach the child waiter instead of aborting it when terminating or dropping a
  `ProcessHandle`, while continuing to abort the I/O helper tasks.
- Cover explicit termination and handle drops for pipe processes, plus queued
  PTY waiters and PTY process-group termination on Unix.

GitOrigin-RevId: 313787f4edec80b30cf5a78f0cc6733f1520d9a4
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-07 20:10:08 +00:00
1 parent 62b7386b07
commit 6db53df37f
2 files changed
+144 -3

No files matched your search

+3 -2
View File
@@ -242,7 +242,7 @@ impl ProcessHandle {
result
}
/// Attempts to kill the child and abort helper tasks.
/// Attempts to kill the child and abort I/O helper tasks.
pub fn terminate(&self) {
self.request_terminate();
@@ -264,7 +264,8 @@ impl ProcessHandle {
if let Ok(mut h) = self.wait_handle.lock()
&& let Some(handle) = h.take()
{
handle.abort();
// Even a queued PTY waiter must run to reap the terminated child.
drop(handle);
}
}
}