From 1b7a9bf149f35e142c32b081c4b183926625c061 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Mon, 23 Oct 2017 01:29:11 -0700 Subject: [PATCH] process: add isExiting This replaces the previously undocumented `_exiting` property with a read-only property giving the same information. Setting the property is restricted to internals, to prevent tampering. Tampering could affect nextTick behavior, for example. --- doc/api/process.md | 11 +++++++ lib/internal/bootstrap_node.js | 9 +++--- lib/internal/process.js | 34 +++++++++++++++++--- lib/internal/process/next_tick.js | 4 +-- src/env.h | 2 +- src/node.cc | 4 ++- test/parallel/test-next-tick-when-exiting.js | 8 ++++- 7 files changed, 59 insertions(+), 13 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 54704e6775da5d..b13bc658872ad8 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1208,6 +1208,17 @@ console.log(process.getgroups()); // [ 27, 30, 46, 1000 ] *Note*: This function is only available on POSIX platforms (i.e. not Windows or Android). +## process.isExiting + + +* {boolean} + +This read-only boolean indicates if the process is currently exiting. That is, +when the `exit` event has been fired and no further scheduled asynchronous code +will run. + ## process.kill(pid[, signal])