From 6859fcf6f7c0710508b2a1f461043547e8a85acc Mon Sep 17 00:00:00 2001 From: legendecas Date: Sun, 17 Nov 2019 20:02:01 +0800 Subject: [PATCH] cli: add --trace-exit cli option It could be convenient to trace abnormal exit of the Node.js processes that printing stacktrace on each `process.exit` call with a cli option. This also takes effects on worker threads. PR-URL: https://github.com/nodejs/node/pull/30516 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/cli.md | 9 +++++ doc/node.1 | 4 +++ src/env.cc | 15 ++++++++ src/node_options.cc | 4 +++ src/node_options.h | 1 + test/parallel/test-trace-exit.js | 59 ++++++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+) create mode 100644 test/parallel/test-trace-exit.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 171f6b8ad29780..745d274e0ccacd 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -784,6 +784,14 @@ added: v7.7.0 Enables the collection of trace event tracing information. +### `--trace-exit` + + +Prints a stack trace whenever an environment is exited proactively, +i.e. invoking `process.exit()`. + ### `--trace-sync-io`