feat(process): public exec.spawn_redirected + exec.wait_any; os.cpu_count#332
Merged
Conversation
…ount (#331) expose the existing os-layer redirected spawn as a Child-returning exec wrapper (stdout/stderr fds, stdin inherited), add a POSIX wait(-1)-shaped exec.wait_any returning the reaped child's handle, and add os.cpu_count: linux popcounts the sched_getaffinity mask (honouring taskset/cgroup cpusets), darwin reads hw.ncpu via __sysctl, windows uses GetActiveProcessorCount(ALL_PROCESSOR_GROUPS). all three never report less than 1. groundwork for the parallel mach test runner (briar-systems/mach#1791). Claude-Session: https://claude.ai/code/session_011wvvqFRodZG3ZgLqerptnr
4 tasks
This was referenced Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #331. Supports briar-systems/mach#1788 (parallel test runner child briar-systems/mach#1791).
exec.spawn_redirected(pathname, argv, envp, stdout_fd, stderr_fd)— Child-returning wrapper over the existingos.spawn_redirected(stdin inherited;-1inherits a stream).exec.wait_any(out_status)— blocking POSIXwait(-1); returns the reaped child's handle so callers juggling several children can map the exit to its work item. The windows os layer already implements pid -1 as a multi-wait across tracked child handles.os.cpu_count()— linux:sched_getaffinitypopcount (added SYS numbers 204/x86_64, 123/generic to all three tables); darwin:hw.ncpuvia__sysctl(202); windows:GetActiveProcessorCount(ALL_PROCESSOR_GROUPS). Clamped ≥ 1, forwarded through every OS/ISA dispatch module.Tests (new-convention labels):
std.process.exec.spawn_redirected:pipes_child_stdout,std.process.exec.wait_any:reaps_each_child_once,std.process.exec.wait_any:errs_with_no_children,std.system.os.cpu_count:at_least_one. Full suite: 571 passed, 0 failed on x86_64-linux.🤖 Generated with Claude Code
https://claude.ai/code/session_011wvvqFRodZG3ZgLqerptnr