Skip to content

fix(moonrun): clear errno for macOS pid fallback#1911

Merged
peter-jerry-ye merged 1 commit into
moonbitlang:mainfrom
peter-jerry-ye:codex/fix-macos-async-pid-errno
Jul 17, 2026
Merged

fix(moonrun): clear errno for macOS pid fallback#1911
peter-jerry-ye merged 1 commit into
moonbitlang:mainfrom
peter-jerry-ye:codex/fix-macos-async-pid-errno

Conversation

@peter-jerry-ye

Copy link
Copy Markdown
Contributor

Why

moonbitlang/async#505 enabled process tests that exposed a macOS-only failure in the WASM async host. The macOS PID-handle path intentionally returns the invalid-handle sentinel to select the kqueue fallback, but unlike the native C implementation it left a stale errno behind. Process::from_pid then interpreted that stale errno as a new failure.

What changed

  • Clear async-host errno after the macOS PID-handle fallback succeeds.
  • Add a WASM integration regression that seeds errno before opening the PID handle and verifies the fallback clears it.

Why this is correct

The change restores parity with the native implementation, which returns the sentinel with errno set to zero. The sentinel still selects the existing kqueue path; only the stale error state is removed.

Scope

The runtime change is limited to the non-Linux Unix PID-handle fallback. Other platforms and process paths are unchanged.

@semanticdiff-com

semanticdiff-com Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/moonrun/src/async_api/process.rs  31% smaller
  crates/moonrun/tests/test_cases/test_async_host.in/main/main.mbt Unsupported file format

@peter-jerry-ye
peter-jerry-ye marked this pull request as ready for review July 17, 2026 08:28
@peter-jerry-ye
peter-jerry-ye merged commit 438c06f into moonbitlang:main Jul 17, 2026
13 checks passed
@peter-jerry-ye
peter-jerry-ye deleted the codex/fix-macos-async-pid-errno branch July 18, 2026 07:37
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