Skip to content

Move pipe nonblocking setup to runtime#486

Merged
peter-jerry-ye merged 1 commit into
mainfrom
codex/fd-util-pipe-runtime
Jul 8, 2026
Merged

Move pipe nonblocking setup to runtime#486
peter-jerry-ye merged 1 commit into
mainfrom
codex/fd-util-pipe-runtime

Conversation

@peter-jerry-ye

@peter-jerry-ye peter-jerry-ye commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Why

Pipe async-end flags should be handled by the runtime side that creates the descriptors. Keeping the old MoonBit-side nonblocking path duplicates responsibility and keeps wasm pipe setup coupled to a platform check.

What

  • Remove the wasm fd_util/set_nonblocking/unix import and MoonBit helper from fd_util.
  • Stop calling the old setter from fd_util/pipe.
  • Keep passing read/write async flags to the runtime pipe import.

Correctness

The runtime pipe import already receives both async-end flags before returning descriptors, so it can set descriptor mode at creation time. This leaves the wasm MoonBit code as a thin caller and avoids changing native async code.

Scope

This branch is based on main and only changes the wasm fd-util pipe path. The moonrun counterpart keeps the old wasm import ABI as a no-op for older guests until the compatibility shim is removed later.

@coveralls

coveralls commented Jul 8, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 792

Coverage increased (+0.04%) to 77.202%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4689
Covered Lines: 3620
Line Coverage: 77.2%
Coverage Strength: 12070.36 hits per line

💛 - Coveralls

@peter-jerry-ye peter-jerry-ye marked this pull request as ready for review July 8, 2026 04:17
@peter-jerry-ye peter-jerry-ye force-pushed the codex/fd-util-pipe-runtime branch from 03cd39a to ba0821b Compare July 8, 2026 04:33
@peter-jerry-ye peter-jerry-ye changed the base branch from codex/async-process to main July 8, 2026 04:33
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

fn SpawnJob::result_handle(job : SpawnJob) -> @fd_util.Fd = "moonbitlang/async" "thread_pool/get_spawn_job_result_handle"

P1 Badge Pass the wasm spawn job handle to the result import

The thread_pool/get_spawn_job_result_handle import is given SpawnJob, but on wasm SpawnJob contains the Job valtype, while the runtime APIs in this file operate on the underlying JobHandle (for example OpenJob::fd_ffi(job.0.handle)). When @process.run or collect_* spawns a wasm process, the host import will not receive the job handle that was submitted, so the returned process handle can be invalid and waiting on the process can fail or hang. Make this import take JobHandle and call it with job.0.handle.


Some(pipe) => pipe.fd()

P2 Badge Preserve blocking stdio for inherited async pipes

When stdout is an existing @pipe.PipeWrite from @pipe.pipe() (whose write end is created async/nonblocking), this now passes that fd directly to the Unix spawn path. The worker only applies posix_spawn_file_actions_adddup2, so the child inherits O_NONBLOCK; a program that writes enough output to fill the pipe can see EAGAIN instead of blocking. The temporary process pipes already have blocking child ends, but arbitrary ProcessOutput still needs child-side blocking without changing the parent's async handle.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@peter-jerry-ye peter-jerry-ye force-pushed the codex/fd-util-pipe-runtime branch from ba0821b to 0e7d8de Compare July 8, 2026 04:51
@peter-jerry-ye peter-jerry-ye merged commit cee2c27 into main Jul 8, 2026
43 of 45 checks passed
@peter-jerry-ye peter-jerry-ye deleted the codex/fd-util-pipe-runtime branch July 8, 2026 07:06
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.

3 participants