From 2cdca4ee0040a97d0b254ea39667774fdd285bcf Mon Sep 17 00:00:00 2001 From: theanarkh Date: Sat, 12 Jul 2025 16:39:12 +0800 Subject: [PATCH] lib: add trace-sigint APIs --- doc/api/util.md | 10 ++++++ lib/internal/process/pre_execution.js | 5 +-- lib/internal/util/trace_sigint.js | 29 ++++++++++++++++++ lib/util.js | 6 ++++ test/parallel/test-trace-sigint-in-worker.js | 20 ++++++++++++ test/pseudo-tty/test-start-trace-sigint.js | 32 ++++++++++++++++++++ test/pseudo-tty/test-start-trace-sigint.out | 11 +++++++ test/pseudo-tty/test-stop-trace-sigint.js | 32 ++++++++++++++++++++ test/pseudo-tty/test-stop-trace-sigint.out | 0 9 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 lib/internal/util/trace_sigint.js create mode 100644 test/parallel/test-trace-sigint-in-worker.js create mode 100644 test/pseudo-tty/test-start-trace-sigint.js create mode 100644 test/pseudo-tty/test-start-trace-sigint.out create mode 100644 test/pseudo-tty/test-stop-trace-sigint.js create mode 100644 test/pseudo-tty/test-stop-trace-sigint.out diff --git a/doc/api/util.md b/doc/api/util.md index 9b6282fc67945b..9d452311aa7468 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -739,6 +739,16 @@ fs.access('file/that/does/not/exist', (err) => { }); ``` +## `util.setTraceSigInt(enable)` + + + +* `enable` {boolean} + +Enable or disable printing a stack trace on `SIGINT`. The API is only available on the main thread. + ## `util.inherits(constructor, superConstructor)`