Skip to content

Commit

Permalink
process_wrap: pass correct stdio flags to libuv
Browse files Browse the repository at this point in the history
  • Loading branch information
santigimeno committed Feb 11, 2018
1 parent 28e7555 commit 04018b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class ModuleWrap;
V(inherit_string, "inherit") \
V(input_string, "input") \
V(internal_string, "internal") \
V(ipc_string, "ipc") \
V(ipv4_string, "IPv4") \
V(ipv6_string, "IPv6") \
V(isclosing_string, "isClosing") \
Expand Down
19 changes: 17 additions & 2 deletions src/process_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,23 @@ class ProcessWrap : public HandleWrap {
if (type->Equals(env->ignore_string())) {
options->stdio[i].flags = UV_IGNORE;
} else if (type->Equals(env->pipe_string())) {
options->stdio[i].flags = static_cast<uv_stdio_flags>(
UV_CREATE_PIPE | UV_READABLE_PIPE | UV_WRITABLE_PIPE);
Local<Value> ipc_val =
stdio->Get(context, env->ipc_string()).ToLocalChecked();
bool ipc = ipc_val->BooleanValue();
unsigned int flags = UV_CREATE_PIPE;
if (ipc) {
flags |= UV_READABLE_PIPE | UV_WRITABLE_PIPE;
} else {
if (i == 0)
flags |= UV_READABLE_PIPE;
else if (i == 1 || i == 2)
flags |= UV_WRITABLE_PIPE;
else
flags |= UV_READABLE_PIPE | UV_WRITABLE_PIPE;
}

options->stdio[i].flags = static_cast<uv_stdio_flags>(flags);

Local<String> handle_key = env->handle_string();
Local<Object> handle =
stdio->Get(context, handle_key).ToLocalChecked().As<Object>();
Expand Down

0 comments on commit 04018b8

Please sign in to comment.