Skip to content

Commit

Permalink
src: exit explicitly after printing V8 help
Browse files Browse the repository at this point in the history
V8 will not exit the process after handling --help anymore:
https://chromium-review.googlesource.com/c/v8/v8/+/2276276

As a drive-by fix, correctly return in the `print_bash_completion`
case as well.

Refs: nodejs#34135
Co-authored-by: Ulan Degenbaev <[email protected]>
  • Loading branch information
addaleax and ulan committed Jun 30, 2020
1 parent c23d2fd commit 7b36cf1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,8 @@ void Init(int* argc,
}

if (per_process::cli_options->print_v8_help) {
// Doesn't return.
V8::SetFlagsFromString("--help", static_cast<size_t>(6));
UNREACHABLE();
exit(0);
}

*argc = argv_.size();
Expand Down Expand Up @@ -1003,13 +1002,16 @@ InitializationResult InitializeOncePerProcess(int argc, char** argv) {
if (per_process::cli_options->print_bash_completion) {
std::string completion = options_parser::GetBashCompletion();
printf("%s\n", completion.c_str());
exit(0);
result.exit_code = 0;
result.early_return = true;
return result;
}

if (per_process::cli_options->print_v8_help) {
// Doesn't return.
V8::SetFlagsFromString("--help", static_cast<size_t>(6));
UNREACHABLE();
result.exit_code = 0;
result.early_return = true;
return result;
}

#if HAVE_OPENSSL
Expand Down

0 comments on commit 7b36cf1

Please sign in to comment.