Skip to content

feat(process): public exec.spawn_redirected + exec.wait_any; os.cpu_count#332

Merged
octalide merged 1 commit into
devfrom
feat/331-process-api
Jul 2, 2026
Merged

feat(process): public exec.spawn_redirected + exec.wait_any; os.cpu_count#332
octalide merged 1 commit into
devfrom
feat/331-process-api

Conversation

@octalide

@octalide octalide commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

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 existing os.spawn_redirected (stdin inherited; -1 inherits a stream).
  • exec.wait_any(out_status) — blocking POSIX wait(-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_getaffinity popcount (added SYS numbers 204/x86_64, 123/generic to all three tables); darwin: hw.ncpu via __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

…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
@octalide octalide marked this pull request as ready for review July 2, 2026 01:04
@octalide octalide merged commit 04eee30 into dev Jul 2, 2026
2 checks passed
@octalide octalide deleted the feat/331-process-api branch July 2, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

process: public exec.spawn_redirected + exec.wait_any; os.cpu_count

1 participant