|
25 | 25 | #include "node_errors.h" |
26 | 26 | #include "node_external_reference.h" |
27 | 27 | #include "node_internals.h" |
| 28 | +#include "stream_wrap.h" |
28 | 29 | #include "string_bytes.h" |
29 | 30 | #include "util-inl.h" |
30 | 31 |
|
@@ -1063,12 +1064,26 @@ Maybe<int> SyncProcessRunner::ParseStdioOption(int child_fd, |
1063 | 1064 | return Nothing<int>(); |
1064 | 1065 | } |
1065 | 1066 | return Just(AddStdioInheritFD(child_fd, inherit_fd)); |
1066 | | - } |
| 1067 | + } else if (js_type->StrictEquals(env()->wrap_string())) { |
| 1068 | + Local<Value> val; |
| 1069 | + if (!js_stdio_option->Get(context, env()->handle_string()).ToLocal(&val)) { |
| 1070 | + return Nothing<int>(); |
| 1071 | + } |
| 1072 | + if (!val->IsObject()) { |
| 1073 | + return Just<int>(UV_EINVAL); |
| 1074 | + } |
| 1075 | + |
| 1076 | + Local<Object> handle = val.As<Object>(); |
| 1077 | + Local<v8::FunctionTemplate> sw = env()->libuv_stream_wrap_ctor_template(); |
| 1078 | + if (sw.IsEmpty() || !sw->HasInstance(handle)) { |
| 1079 | + return Just<int>(UV_EINVAL); |
| 1080 | + } |
1067 | 1081 |
|
1068 | | - Utf8Value stdio_type(env()->isolate(), js_type); |
1069 | | - fprintf(stderr, "invalid child stdio type: %s\n", stdio_type.out()); |
| 1082 | + uv_stream_t* stream = LibuvStreamWrap::From(env(), handle)->stream(); |
| 1083 | + return Just(AddStdioInheritStream(child_fd, stream)); |
| 1084 | + } |
1070 | 1085 |
|
1071 | | - UNREACHABLE(); |
| 1086 | + return Just<int>(UV_EINVAL); |
1072 | 1087 | } |
1073 | 1088 |
|
1074 | 1089 | int SyncProcessRunner::AddStdioIgnore(uint32_t child_fd) { |
@@ -1116,6 +1131,18 @@ int SyncProcessRunner::AddStdioInheritFD(uint32_t child_fd, int inherit_fd) { |
1116 | 1131 | return 0; |
1117 | 1132 | } |
1118 | 1133 |
|
| 1134 | + |
| 1135 | +int SyncProcessRunner::AddStdioInheritStream(uint32_t child_fd, |
| 1136 | + uv_stream_t* stream) { |
| 1137 | + CHECK_LT(child_fd, stdio_count_); |
| 1138 | + CHECK(!stdio_pipes_[child_fd]); |
| 1139 | + |
| 1140 | + uv_stdio_containers_[child_fd].flags = UV_INHERIT_STREAM; |
| 1141 | + uv_stdio_containers_[child_fd].data.stream = stream; |
| 1142 | + |
| 1143 | + return 0; |
| 1144 | +} |
| 1145 | + |
1119 | 1146 | Maybe<int> SyncProcessRunner::CopyJsString(Local<Value> js_value, |
1120 | 1147 | const char** target) { |
1121 | 1148 | Isolate* isolate = env()->isolate(); |
|
0 commit comments