Skip to content

Commit 3446ff4

Browse files
committed
tty: do not add shutdown method to handle
UV_TTY does not support `uv_shutdown()` so adding this method in StreamBase will cause an `abort()` in C land. Fix: #1068 PR-URL: #1073 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 9d2b89d commit 3446ff4

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

src/stream_base-inl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ void StreamBase::AddMethods(Environment* env,
3737

3838
env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStart>);
3939
env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStop>);
40-
env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>);
40+
if ((flags & kFlagNoShutdown) == 0)
41+
env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>);
4142
if ((flags & kFlagHasWritev) != 0)
4243
env->SetProtoMethod(t, "writev", JSMethod<Base, &StreamBase::Writev>);
4344
env->SetProtoMethod(t,

src/stream_base.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class StreamBase : public StreamResource {
160160
public:
161161
enum Flags {
162162
kFlagNone = 0x0,
163-
kFlagHasWritev = 0x1
163+
kFlagHasWritev = 0x1,
164+
kFlagNoShutdown = 0x2
164165
};
165166

166167
template <class Base>

src/tty_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void TTYWrap::Initialize(Handle<Object> target,
3939
env->SetProtoMethod(t, "close", HandleWrap::Close);
4040
env->SetProtoMethod(t, "unref", HandleWrap::Unref);
4141

42-
StreamWrap::AddMethods(env, t);
42+
StreamWrap::AddMethods(env, t, StreamBase::kFlagNoShutdown);
4343

4444
env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize);
4545
env->SetProtoMethod(t, "setRawMode", SetRawMode);
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
process.stdin.emit('end');

0 commit comments

Comments
 (0)