summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDenys Otrishko <shishugi@gmail.com>2018-07-10 18:44:16 +0300
committerAnna Henningsen <anna@addaleax.net>2018-07-14 12:04:53 +0200
commit35326f27fd9693fcf02a2eab5e22c78b0b702508 (patch)
tree1da6a8b0e92039e670ad352ebfdf11b447737a1f /src
parent998f9ffd429e10b712b06ea57e598d4b1a55fe64 (diff)
downloadandroid-node-v8-35326f27fd9693fcf02a2eab5e22c78b0b702508.tar.gz
android-node-v8-35326f27fd9693fcf02a2eab5e22c78b0b702508.tar.bz2
android-node-v8-35326f27fd9693fcf02a2eab5e22c78b0b702508.zip
process: fix process.exitCode handling for fatalException
* set process.exitCode before calling 'exit' handlers so that there will not be a situation where process.exitCode !== code in 'exit' callback during uncaughtException handling * don't ignore process.exitCode set in 'exit' callback when failed with uncaughtException and there is no uncaughtException listener PR-URL: https://github.com/nodejs/node/pull/21739 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src')
-rw-r--r--src/node.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/node.cc b/src/node.cc
index 1fbd43b26c..4c1ee8f18a 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -1439,7 +1439,16 @@ void FatalException(Isolate* isolate,
exit(7);
} else if (caught->IsFalse()) {
ReportException(env, error, message);
- exit(1);
+
+ // fatal_exception_function call before may have set a new exit code ->
+ // read it again, otherwise use default for uncaughtException 1
+ Local<String> exit_code = env->exit_code_string();
+ Local<Value> code;
+ if (!process_object->Get(env->context(), exit_code).ToLocal(&code) ||
+ !code->IsInt32()) {
+ exit(1);
+ }
+ exit(code.As<v8::Int32>()->Value());
}
}
}