[d8] cleanly force exit in d8 on windows.
Using _exit on windows may cause race conditions in threads. BUG=chromium:603131 Review-Url: https://codereview.chromium.org/2478473003 Cr-Commit-Position: refs/heads/master@{#40789}
This commit is contained in:
parent
76bd4ff492
commit
639f6f1774
@ -772,4 +772,12 @@ void Shell::AddOSMethods(Isolate* isolate, Local<ObjectTemplate> os_templ) {
|
||||
FunctionTemplate::New(isolate, RemoveDirectory));
|
||||
}
|
||||
|
||||
void Shell::Exit(int exit_code) {
|
||||
// Use _exit instead of exit to avoid races between isolate
|
||||
// threads and static destructors.
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
_exit(exit_code);
|
||||
}
|
||||
|
||||
} // namespace v8
|
||||
|
@ -10,5 +10,12 @@ namespace v8 {
|
||||
|
||||
void Shell::AddOSMethods(Isolate* isolate, Local<ObjectTemplate> os_templ) {}
|
||||
|
||||
void Shell::Exit(int exit_code) {
|
||||
// Use TerminateProcess avoid races between isolate threads and
|
||||
// static destructors.
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
TerminateProcess(GetCurrentProcess(), exit_code);
|
||||
}
|
||||
|
||||
} // namespace v8
|
||||
|
10
src/d8.cc
10
src/d8.cc
@ -1569,16 +1569,6 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
|
||||
return handle_scope.Escape(context);
|
||||
}
|
||||
|
||||
|
||||
void Shell::Exit(int exit_code) {
|
||||
// Use _exit instead of exit to avoid races between isolate
|
||||
// threads and static destructors.
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
_exit(exit_code);
|
||||
}
|
||||
|
||||
|
||||
struct CounterAndKey {
|
||||
Counter* counter;
|
||||
const char* key;
|
||||
|
Loading…
Reference in New Issue
Block a user