libuv-wasix: posix_spawn child processes on WASIX#7
Conversation
|
Supersedes #1 (now closed as duplicate). Branch EdgeJS verification (via
|
|
Update: restored the real `uv__spawn_and_init_child_fork()` implementation from before ea792e2. Fork is only disabled when both `wasi` and `wasm_exception_handling` are defined (wasixcc exnref/EH builds). Non-EH WASIX uses asyncify and can fork normally; EH builds still fall through to the posix_spawn path via `UV_ENOSYS`. Commit: 1b66832 |
1b66832 to
ff7c7ca
Compare
|
Rebased `fix/spawn-posix-v2` onto `wasix-1.51.0` and retargeted this PR. New tip: `ff7c7ca8` (3 commits on top of libuv 1.51.0 + wasix build scripts). Drops the old `ubi`/`disable fork` history; fork is restored with an EH-only `UV_ENOSYS` stub (`wasm_exception_handling`). |
…ct avoids the unsupported AF_UNSPEC connect() trick. WASIX connected-state checks now trust libuv’s handle flag.
Replace the fake fork success stub with a WASIX posix_spawnp backend and reap children through libc waitpid(WNOHANG) instead of direct __wasi_* calls. - Dispatch posix_spawnp from uv__spawn_resolve_and_spawn on __wasi__ - Return UV_ENOSYS from the fork fallback so failed spawns fail fast - Poll uv__wait_children after uv__io_poll and cap backend timeout when process handles are pending (no reliable SIGCHLD on WASIX) - Use uv_pipe for unidirectional child stdio where socketpair is unreliable Co-authored-by: Cursor <cursoragent@cursor.com>
Move child-exit polling out of uv__backend_timeout so uv_backend_timeout() and timer-driven poll deadlines stay accurate. When a spawned child is still tracked and the loop would poll forever, cap that single poll to UV__WASIX_CHILD_POLL_MS before calling uv__io_poll(). Co-authored-by: Cursor <cursoragent@cursor.com>
|
Fix: restored the two `ubi` commits that sit between `wasix-1.51.0` and `disable fork`:
These were dropped when rebasing directly onto `wasix-1.51.0`. The branch now has 5 commits on top of `wasix-1.51.0` (tip `4923dd2d`), still without `ea792e22 disable fork`. ``` |
ff7c7ca to
4923dd2
Compare
Track cb7e09ae on wasix-1.51.0 so WASIX child_process uses the squashed spawn, waitpid polling, and EH-gated fork fallback from wasix-org/libuv#7. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Replace broken WASIX child-process behavior with a
posix_spawnp()backend for wasm EH builds, while preserving realfork()on WASIX without exception handling.posix_spawnpfromuv__spawn_resolve_and_spawnon__wasi__waitpid(WNOHANG)(no direct__wasi_*imports in libuv)uv__wait_children()afteruv__io_poll(); only cap unbounded poll sleep (timeout < 0) toUV__WASIX_CHILD_POLL_MSat the poll call siteUV_ENOSYSfrom the fork fallback only when__wasi__ && __wasm_exception_handling__(EH/asyncify-incompatible); restore normal fork otherwiseuv_pipe()for unidirectional child stdio wheresocketpair(AF_UNIX)is unreliable on WASIXRebased onto
wasix-1.51.0(supersedes #1, closed as duplicate).Test plan
EdgeJS WASIX (EH build,
scripts/edge-wasix-node-runner.sh, libuvff7c7ca8):spawnSync(process.execPath, ['-e', ...])(~330–380ms each)-eargv preservationcross-spawn.sync(process.execPath, ...)