← board

Process spawning and execution support — libc-free execve pipeline

Goal

Provide a statically-linked, libc-free process spawning API using raw system calls (sys_vfork, sys_execve, sys_pipe2, sys_dup2, sys_wait4).

Surface (sketch)

In lib/rtl/platform.pas:

In a new process control unit or sysutils:

Implementation Steps

  1. Expose the raw system calls per architecture.
  2. Implement safety wrapper for child execution under sys_vfork/sys_clone: the child must call sys_execve or sys_exit directly without returning to the caller function to prevent clobbering the parent stack.
  3. Manage pipe descriptors and redirect stdin/stdout of the child process.

Log

Update (2026-06-22, Track B)

DONE on host (2026-06-22, Track B)

All three items landed and verified on x86-64:

  1. raw-syscall pipeline (vfork/execve/pipe2/dup2/wait4) — was already in place.
  2. O_CLOEXEC pipes — concurrent children no longer leak each other's fds (regression: test/lib_process_multi.pas).
  3. PalKill (sys_kill) — SIGSTOP/SIGCONT/SIGTERM children (used by the player's audio).
  4. Child-stack safety SOLVED by switching to real fork (own COW address space) instead of vfork/clone(CLONE_VM|VFORK). The "child must exec without returning" hazard is gone — the child can run its dup2/close/execve path safely. x86-64 SYS_fork; aarch64 clone(SIGCHLD).

Verified x86-64: lib_process, lib_process_multi, video player + audio, full lib-test. Remaining: i386/arm32/aarch64 are the same mechanical change but need a qemu cross smoke (Track A make test-i386/aarch64/arm32). Closing the host work; reopen a focused cross-validation ticket if a target diverges.