Skip to content

Commit

Permalink
src: call Environment::Exit() for fatal exceptions
Browse files Browse the repository at this point in the history
Call `Environment::Exit()` rather than the process-wide
`exit()` function, since JS exceptions generally only affect
the current JS engine instance.

PR-URL: #25472
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
addaleax authored and joyeecheung committed Jan 16, 2019
1 parent 84e90de commit 8528c21
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/node_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ TryCatchScope::~TryCatchScope() {
if (HasCaught() && !HasTerminated() && mode_ == CatchMode::kFatal) {
HandleScope scope(env_->isolate());
ReportException(env_, Exception(), Message());
exit(7);
env_->Exit(7);
}
}

Expand Down Expand Up @@ -711,7 +711,7 @@ void FatalException(Isolate* isolate,
// Failed before the process._fatalException function was added!
// this is probably pretty bad. Nothing to do but report and exit.
ReportException(env, error, message);
exit(6);
env->Exit(6);
} else {
errors::TryCatchScope fatal_try_catch(env);

Expand All @@ -727,7 +727,7 @@ void FatalException(Isolate* isolate,
if (fatal_try_catch.HasCaught()) {
// The fatal exception function threw, so we must exit
ReportException(env, fatal_try_catch);
exit(7);
env->Exit(7);

} else if (caught.ToLocalChecked()->IsFalse()) {
ReportException(env, error, message);
Expand All @@ -738,9 +738,9 @@ void FatalException(Isolate* isolate,
Local<Value> code;
if (!process_object->Get(env->context(), exit_code).ToLocal(&code) ||
!code->IsInt32()) {
exit(1);
env->Exit(1);
}
exit(code.As<Int32>()->Value());
env->Exit(code.As<Int32>()->Value());
}
}
}
Expand Down

0 comments on commit 8528c21

Please sign in to comment.