Skip to content

win,unix: add uv_pipe_open_ex - #5160

Closed
PickBas wants to merge 1 commit into
libuv:v1.xfrom
JaneaSystems:win-pipe-handle
Closed

win,unix: add uv_pipe_open_ex#5160
PickBas wants to merge 1 commit into
libuv:v1.xfrom
JaneaSystems:win-pipe-handle

Conversation

@PickBas

@PickBas PickBas commented Jun 9, 2026

Copy link
Copy Markdown

win,unix: add uv_pipe_open_ex

Adds uv_pipe_open_ex(), which opens a pipe from a native OS handle (HANDLE on Windows, file descriptor on Unix).

On Windows, uv_pipe_open() interprets its argument as a CRT file descriptor via _get_osfhandle(). A raw HANDLE with no CRT fd, e.g. an inherited anonymous pipe handle (CreatePipe, .NET AnonymousPipeServerStream), fails with UV_EBADF, and no workaround exists since CRT fds are not inheritable. Implements the approach suggested in this comment. On Unix the call is equivalent to uv_pipe_open().

The handle is owned by libuv after a successful call; on failure it remains owned by the caller. Test covers a raw CreatePipe() handle (no CRT fd, non-overlapped) on Windows.

Refs: nodejs/node#57288

uv_pipe_open() interprets its argument as a CRT file
descriptor on Windows, so a raw HANDLE without
one (e.g. an inherited anonymous pipe) fails.

uv_pipe_open_ex() accepts the native OS handle directly.
On Unix it is equivalent to uv_pipe_open().

Refs: nodejs/node#57288
Signed-off-by: PickBas <sayed.kirill@gmail.com>
@vtjnash

vtjnash commented Jun 9, 2026

Copy link
Copy Markdown
Member

Not sure this is necessary, since it has been available in v2 for many years now. Notably we already provide uv_pipe also, which makes the platform-specific API usage being added here for v1 unnecessary.

@vtjnash

vtjnash commented Jun 9, 2026

Copy link
Copy Markdown
Member

Legacy consumers of v1.x (mainly nodejs) also have the option of calling _open_osfhandle, as that's kinda the point of staying with v1.x legacy

@PickBas

PickBas commented Jul 1, 2026

Copy link
Copy Markdown
Author

Appreciate the feedback. I'm closing this PR in favor of nodejs/node#63851

@PickBas PickBas closed this Jul 1, 2026
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.

2 participants