Extend child commands with session and descriptor controls (#47604)

## What changed

- Add `ProcessMode::NewSession`, null stdin, and opt-in Linux parent-death termination to the shared child command API.
- Replace `DescriptorPolicy::StdioOnly` with `Explicit` and add `preserve_fds` to allow selected inheritable Unix descriptors alongside stdio. Preserve descriptor numbers without duplicating or closing the parent's descriptors, keeping POSIX record locks intact.
- Support session creation and preserved descriptors in the native macOS backend, with a compatible fallback for high descriptor numbers rejected by native file actions.

## Testing

Add regression coverage for process groups and sessions, descriptor preservation across native and executable-text launches, the last descriptor slot below the file limit, and retention of parent record locks.

GitOrigin-RevId: 29ecd859d3b673da6ae6412cc06a32fa10d11346
This commit is contained in:
Charlie Marsh
2026-09-23 17:59:47 +00:00
committed by copyberry
parent 897b7ae285
commit b8d365b18e
7 changed files with 315 additions and 44 deletions
+1 -1
View File
@@ -531,7 +531,7 @@ pub(crate) fn spawn_command(
command.fallback(SpawnFallback::ReturnError);
// macOS cannot receive passed fds with close-on-exec set atomically.
#[cfg(target_os = "macos")]
command.descriptor_policy(DescriptorPolicy::StdioOnly);
command.descriptor_policy(DescriptorPolicy::Explicit);
command.spawn().map_err(io_error)
}