Skip to content

Commit 67c8511

Browse files
committed
src: use internal/errors for startSigintWatchdog
Move the throw out of c++ and into js using internal/errors PR-URL: #16546 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 94b2be7 commit 67c8511

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

doc/api/errors.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,11 @@ Used when attempting to perform an operation outside the bounds of a `Buffer`.
615615
Used when an attempt has been made to create a `Buffer` larger than the
616616
maximum allowed size.
617617

618+
<a id="ERR_CANNOT_WATCH_SIGINT"></a>
619+
### ERR_CANNOT_WATCH_SIGINT
620+
621+
Used when Node.js is unable to watch for the `SIGINT` signal.
622+
618623
<a id="ERR_CHILD_CLOSED_BEFORE_REPLY"></a>
619624
### ERR_CHILD_CLOSED_BEFORE_REPLY
620625

lib/internal/errors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ E('ERR_ASYNC_TYPE', (s) => `Invalid name for async "type": ${s}`);
151151
E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds);
152152
E('ERR_BUFFER_TOO_LARGE',
153153
`Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`);
154+
E('ERR_CANNOT_WATCH_SIGINT', 'Cannot watch for SIGINT signals');
154155
E('ERR_CHILD_CLOSED_BEFORE_REPLY', 'Child closed before reply received');
155156
E('ERR_CONSOLE_WRITABLE_STREAM',
156157
'Console expects a writable stream instance for %s');

lib/repl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ function REPLServer(prompt,
227227
if (self.breakEvalOnSigint) {
228228
// Start the SIGINT watchdog before entering raw mode so that a very
229229
// quick Ctrl+C doesn't lead to aborting the process completely.
230-
utilBinding.startSigintWatchdog();
230+
if (!utilBinding.startSigintWatchdog())
231+
throw new errors.Error('ERR_CANNOT_WATCH_SIGINT');
231232
previouslyInRawMode = self._setRawMode(false);
232233
}
233234

src/node_util.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) {
135135

136136
void StartSigintWatchdog(const FunctionCallbackInfo<Value>& args) {
137137
int ret = SigintWatchdogHelper::GetInstance()->Start();
138-
if (ret != 0) {
139-
Environment* env = Environment::GetCurrent(args);
140-
env->ThrowErrnoException(ret, "StartSigintWatchdog");
141-
}
138+
args.GetReturnValue().Set(ret == 0);
142139
}
143140

144141

0 commit comments

Comments
 (0)