unix,spawn: respect user stdio flags for new pipe
`UV_READABLE_PIPE` and `UV_WRITABLE_PIPE` flags should be honored on unices. Windows is better about already doing this, so this will make the behavior of these flags more consistent across platforms. It also is just better to set these flags to reflect the actual mode of the stream, rather than guessing at it based on typical usage. Refs: https://github.com/libuv/libuv/pull/1655 Refs: https://github.com/nodejs/node/pull/18701 PR-URL: https://github.com/libuv/libuv/pull/1741 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
parent
cef8a4624b
commit
c409b3fcff
@ -223,8 +223,7 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) {
|
||||
|
||||
|
||||
static int uv__process_open_stream(uv_stdio_container_t* container,
|
||||
int pipefds[2],
|
||||
int writable) {
|
||||
int pipefds[2]) {
|
||||
int flags;
|
||||
int err;
|
||||
|
||||
@ -238,13 +237,11 @@ static int uv__process_open_stream(uv_stdio_container_t* container,
|
||||
pipefds[1] = -1;
|
||||
uv__nonblock(pipefds[0], 1);
|
||||
|
||||
if (container->data.stream->type == UV_NAMED_PIPE &&
|
||||
((uv_pipe_t*)container->data.stream)->ipc)
|
||||
flags = UV_STREAM_READABLE | UV_STREAM_WRITABLE;
|
||||
else if (writable)
|
||||
flags = UV_STREAM_WRITABLE;
|
||||
else
|
||||
flags = UV_STREAM_READABLE;
|
||||
flags = 0;
|
||||
if (container->flags & UV_WRITABLE_PIPE)
|
||||
flags |= UV_STREAM_READABLE;
|
||||
if (container->flags & UV_READABLE_PIPE)
|
||||
flags |= UV_STREAM_WRITABLE;
|
||||
|
||||
return uv__stream_open(container->data.stream, pipefds[0], flags);
|
||||
}
|
||||
@ -533,7 +530,7 @@ int uv_spawn(uv_loop_t* loop,
|
||||
uv__close_nocheckstdio(signal_pipe[0]);
|
||||
|
||||
for (i = 0; i < options->stdio_count; i++) {
|
||||
err = uv__process_open_stream(options->stdio + i, pipes[i], i == 0);
|
||||
err = uv__process_open_stream(options->stdio + i, pipes[i]);
|
||||
if (err == 0)
|
||||
continue;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user