deno
acdf3904 - fix(io): remove global stdio statics, handle non-blocking stdin (#33219)

Commit
129 days ago
fix(io): remove global stdio statics, handle non-blocking stdin (#33219) ## Summary - Remove `STDIN_HANDLE`/`STDOUT_HANDLE`/`STDERR_HANDLE` global `Lazy<StdFile>` statics that wrapped raw stdio fds 0/1/2 - Replace with local `stdio_fd()` helper + `Drop` impl that leaks stdio fds to prevent closing them at shutdown - Add `WouldBlock` retry loops in stdin `read_sync` and `read_byob` to handle `O_NONBLOCK` leakage from Node's `process.stdin` (which sets non-blocking mode via `uv_pipe_open`/`uv_tty_init`) - Add `console_size_of_stderr()` to avoid depending on the removed statics ### Why remove the statics? The global statics create ownership conflicts when Node's `process.stdin`/`stdout`/`stderr` also wraps fds 0/1/2 via libuv handles. Both the static and the libuv handle claim ownership of the same fd. Removing the statics is the first step toward single-owner stdio fd management, where libuv handles are the sole owners and `Deno.stdin`/`stdout`/`stderr` delegate to them. ### Why WouldBlock retry? Node's `process.stdin` uses `uv_pipe_open(0)` which sets `O_NONBLOCK` on fd 0. Since `O_NONBLOCK` is per-file-description (not per-fd), this affects all users of that fd including `Deno.stdin`. The retry loop handles `EAGAIN` gracefully instead of surfacing it to JavaScript. This matches libuv's approach where the parent process uses non-blocking I/O and child processes clear `O_NONBLOCK` in `pre_exec`. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Parents
Loading