diff --git a/doc/api/errors.md b/doc/api/errors.md index 6d8eed949203e3..d0e2512c04fff2 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -615,6 +615,11 @@ Used when attempting to perform an operation outside the bounds of a `Buffer`. Used when an attempt has been made to create a `Buffer` larger than the maximum allowed size. + +### ERR_CANNOT_WATCH_SIGINT + +Used when Node.js is unable to watch for the `SIGINT` signal. + ### ERR_CHILD_CLOSED_BEFORE_REPLY diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 6f056b1ef8bec1..8171216fbf8fbb 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -151,6 +151,7 @@ E('ERR_ASYNC_TYPE', (s) => `Invalid name for async "type": ${s}`); E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds); E('ERR_BUFFER_TOO_LARGE', `Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`); +E('ERR_CANNOT_WATCH_SIGINT', 'Cannot watch for SIGINT signals'); E('ERR_CHILD_CLOSED_BEFORE_REPLY', 'Child closed before reply received'); E('ERR_CONSOLE_WRITABLE_STREAM', 'Console expects a writable stream instance for %s'); diff --git a/lib/repl.js b/lib/repl.js index d4b95bf3a67f45..73de1797969a6b 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -227,7 +227,8 @@ function REPLServer(prompt, if (self.breakEvalOnSigint) { // Start the SIGINT watchdog before entering raw mode so that a very // quick Ctrl+C doesn't lead to aborting the process completely. - utilBinding.startSigintWatchdog(); + if (!utilBinding.startSigintWatchdog()) + throw new errors.Error('ERR_CANNOT_WATCH_SIGINT'); previouslyInRawMode = self._setRawMode(false); } diff --git a/src/node_util.cc b/src/node_util.cc index cf26eca692e6ed..fa30ae447220aa 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -135,10 +135,7 @@ static void SetHiddenValue(const FunctionCallbackInfo& args) { void StartSigintWatchdog(const FunctionCallbackInfo& args) { int ret = SigintWatchdogHelper::GetInstance()->Start(); - if (ret != 0) { - Environment* env = Environment::GetCurrent(args); - env->ThrowErrnoException(ret, "StartSigintWatchdog"); - } + args.GetReturnValue().Set(ret == 0); }