From 62a0f763a7d1a5bbaa2670b9d2687ba183d2c528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Linse?= Date: Wed, 28 Mar 2018 19:07:29 +0200 Subject: [PATCH] win,process: allow child pipe handles to be opened in overlapped mode PR-URL: https://github.com/libuv/libuv/pull/1784 Reviewed-By: Bartosz Sosnowski Reviewed-By: Bert Belder --- docs/src/process.rst | 5 +++++ include/uv.h | 8 +++++++- src/win/process-stdio.c | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/src/process.rst b/docs/src/process.rst index ecc3cbf3..bc968554 100644 --- a/docs/src/process.rst +++ b/docs/src/process.rst @@ -109,6 +109,11 @@ Data types */ UV_READABLE_PIPE = 0x10, UV_WRITABLE_PIPE = 0x20 + /* + * Open the child pipe handle in overlapped mode on Windows. + * On Unix it is silently ignored. + */ + UV_OVERLAPPED_PIPE = 0x40 } uv_stdio_flags; diff --git a/include/uv.h b/include/uv.h index 5ac01d59..7e4b52ba 100644 --- a/include/uv.h +++ b/include/uv.h @@ -866,7 +866,13 @@ typedef enum { * flags may be specified to create a duplex data stream. */ UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 + UV_WRITABLE_PIPE = 0x20, + + /* + * Open the child pipe handle in overlapped mode on Windows. + * On Unix it is silently ignored. + */ + UV_OVERLAPPED_PIPE = 0x40 } uv_stdio_flags; typedef struct uv_stdio_container_s { diff --git a/src/win/process-stdio.c b/src/win/process-stdio.c index 84cab473..4c8e11ac 100644 --- a/src/win/process-stdio.c +++ b/src/win/process-stdio.c @@ -131,12 +131,13 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop, sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; + BOOL overlap = server_pipe->ipc || (flags & UV_OVERLAPPED_PIPE); child_pipe = CreateFileA(pipe_name, client_access, 0, &sa, OPEN_EXISTING, - server_pipe->ipc ? FILE_FLAG_OVERLAPPED : 0, + overlap ? FILE_FLAG_OVERLAPPED : 0, NULL); if (child_pipe == INVALID_HANDLE_VALUE) { err = GetLastError();