Skip to content

os: support child processes on Linux and Darwin - #5699

Draft
yohimik wants to merge 5 commits into
tinygo-org:devfrom
yohimik:upstream-pr/os-exec-posix-spawn
Draft

yohimik wants to merge 5 commits into
tinygo-org:devfrom
yohimik:upstream-pr/os-exec-posix-spawn

Conversation

@yohimik

@yohimik yohimik commented Sep 17, 2026

Copy link
Copy Markdown

Addresses #5695. os/exec cannot start commands with standard file descriptors. Use posix_spawn and implement file mapping, working directory, wait, exit status, and signals.

Darwin needs #5612 and #5694 (PR #5701). Concurrent pipe and process creation needs #5692 (PR #5697). Those implementations are separate.

Tests cover file mappings, descriptor closure, process state, and refused attributes. Earlier Linux and Darwin tests used released compilers with source overlays. WaitDelay and interruptible pipe I/O remain unresolved. Only Setpgid and Pgid are supported in SysProcAttr. Darwin working directory support needs macOS 10.15 or later.

Replaces #5634, closed on 17 September 2026 with a request for an issue first. Based on dev at 93940cb6. Patches are unchanged after rebase. Formatting and whitespace checks pass. New runtime tests and CI are pending.

Use posix_spawn on hosted Linux and Darwin. Map process files, apply the
working directory and process group, and clear the child signal mask.
Use wait4 for process status and support Kill and Signal.

Mark Darwin pipes close-on-exec under ForkLock. Darwin also needs the
fcntl wrapper in PR tinygo-org#5612 and the libSystem symbols in PR tinygo-org#5636.
Concurrent spawn and pipe creation need the RWMutex fix in PR tinygo-org#5630.

Keep the process stubs on other targets and add process regression tests.
Open /dev/null in the child before closing a nil or unnamed descriptor. Save remap sources before these actions. This avoids a parent descriptor check and its race with concurrent open.

Use descriptor reads and exec redirection in remap tests. Check nil slots and temporary descriptors. The tests pass with ordinary Go on Darwin and Linux. Both TinyGo os suites pass with released compiler source overlays. Darwin also needs the addopen symbol from PR tinygo-org#5636.
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.

1 participant