From 3446ff417ba1e11d35d1661b8788eac5af029360 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 5 Mar 2015 11:04:00 -0500 Subject: [PATCH] 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: https://github.com/iojs/io.js/issues/1068 PR-URL: https://github.com/iojs/io.js/pull/1073 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- src/stream_base-inl.h | 3 ++- src/stream_base.h | 3 ++- src/tty_wrap.cc | 2 +- test/parallel/test-regress-GH-io-1068.js | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-regress-GH-io-1068.js diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 490909456b3624..46d9f78905f2eb 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -37,7 +37,8 @@ void StreamBase::AddMethods(Environment* env, env->SetProtoMethod(t, "readStart", JSMethod); env->SetProtoMethod(t, "readStop", JSMethod); - env->SetProtoMethod(t, "shutdown", JSMethod); + if ((flags & kFlagNoShutdown) == 0) + env->SetProtoMethod(t, "shutdown", JSMethod); if ((flags & kFlagHasWritev) != 0) env->SetProtoMethod(t, "writev", JSMethod); env->SetProtoMethod(t, diff --git a/src/stream_base.h b/src/stream_base.h index dcbde09bacf25d..5718f07ae14d29 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -160,7 +160,8 @@ class StreamBase : public StreamResource { public: enum Flags { kFlagNone = 0x0, - kFlagHasWritev = 0x1 + kFlagHasWritev = 0x1, + kFlagNoShutdown = 0x2 }; template diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index 186f2f0100162e..eaec271937530e 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -39,7 +39,7 @@ void TTYWrap::Initialize(Handle target, env->SetProtoMethod(t, "close", HandleWrap::Close); env->SetProtoMethod(t, "unref", HandleWrap::Unref); - StreamWrap::AddMethods(env, t); + StreamWrap::AddMethods(env, t, StreamBase::kFlagNoShutdown); env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize); env->SetProtoMethod(t, "setRawMode", SetRawMode); diff --git a/test/parallel/test-regress-GH-io-1068.js b/test/parallel/test-regress-GH-io-1068.js new file mode 100644 index 00000000000000..e769e6b81a880d --- /dev/null +++ b/test/parallel/test-regress-GH-io-1068.js @@ -0,0 +1 @@ +process.stdin.emit('end');