You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Process.run: a grandchild that keeps writing makes C answer Fail where JS answers Done #1051
Fail{(27, "File too large")} (output past max_output)
JS (Bun)
Done{(0, ("hi\n", ""))}
Observed on macOS arm64 on main at 168534f, right after #1030. Both lanes leave the yes running, as the guide documents ("Timeouts do not kill descendants").
Cause
After #1030's review, the C loop in bend2/effs/process_run.c (process_call, lines 161–205) reaps the direct child on every pass. Once it has exited, the loop polls with a 0 ms timeout and stops only when a poll returns nothing ready (line 205) or every pipe is closed (line 189). A grandchild that never stops writing keeps the pipe readable, so the loop keeps draining until the output passes max_output. The deadline no longer applies at that point either (line 175 checks it only while the child is alive).
A grandchild that writes slowly ((while :; do echo x; sleep 0.01; done) & echo hi) does not trigger it: the drain finds an empty poll and stops, and both lanes answer Done. They differ only in how many x lines they catch, which is a timing race.
It cannot hang, because the output stays capped by max_output, but the two lanes should answer the same thing.
Possible fix
Once the direct child has been reaped, drain in a single pass: read only what is readable at that moment (for example, bounded by FIONREAD per pipe, or by one poll and read round), then stop. That matches what the guide promises ("The call waits for the direct child and drains ready output; a descendant holding an inherited pipe open does not extend the wait") and what Bun.spawnSync does.
A test in tests/io/process_run.bend with the call above and an exact expected result would keep the lanes in step.
Activity
Process.run stops at the child's exit: a descendant holding its pipes…