From b87312ba086ea5a99e475c77c496635f96e7b23e Mon Sep 17 00:00:00 2001 From: theanarkh Date: Mon, 11 Aug 2025 17:14:44 +0800 Subject: [PATCH] lib: add trace-sigint APIs PR-URL: https://github.com/nodejs/node/pull/59040 Reviewed-By: Chengzhong Wu --- 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 9b6282fc67..9d452311aa 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)`