vm,repl: (add ability to) break on sigint/ctrl+c
Checklist
-
tests and code linting passes -
a test and/or benchmark is included -
documentation is changed or added -
the commit message follows commit guidelines
Affected core subsystem(s)
vm, repl
Description of change
vm:
- Adds the
breakEvalOnSigint
option tovm.runIn(This)Context
. This uses a watchdog thread to wait for SIGINT and generally works just like the existingtimeout
option. - Adds a method to the existing timer-based watchdog to check if it stopped regularly or by running into the timeout. This is used to tell a SIGINT abort from a timer-based one.
- Adds (internal)
process._{start,stop}SigintWatchdog
methods to start/stop the watchdog thread used by the above option manually. This will be used in the REPL to set up SIGINT handling before entering terminal raw mode, so that there is no time window in which Ctrl+C fully aborts the process.
readline:
- Return the previous raw mode setting from the internal
_setRawMode
so that is easier to reset it to its original state later.
repl: Use all that stuff to fix #6612 (closed). This probably does not work on Windows as-is.
Current CI: https://ci.nodejs.org/job/node-test-commit/3222/