diff --git a/src/main/cpp/blaze_util_platform.h b/src/main/cpp/blaze_util_platform.h index 7599798422f851..e8a15c222f36a6 100644 --- a/src/main/cpp/blaze_util_platform.h +++ b/src/main/cpp/blaze_util_platform.h @@ -77,22 +77,23 @@ class SignalHandler { typedef void (* Callback)(); static SignalHandler& Get() { return INSTANCE; } - GlobalVariables* GetGlobals() { return _globals; } - void CancelServer() { _cancel_server(); } + GlobalVariables* GetGlobals() const { return globals_; } + const std::string& GetProductName() const { return product_name_; } + const std::string& GetOutputBase() const { return output_base_; } + void CancelServer() { cancel_server_(); } void Install(const std::string &product_name, const std::string &output_base, GlobalVariables* globals, Callback cancel_server); ATTRIBUTE_NORETURN void PropagateSignalOrExit(int exit_code); - std::string _product_name; - std::string _output_base; - private: static SignalHandler INSTANCE; - GlobalVariables* _globals; - Callback _cancel_server; + std::string product_name_; + std::string output_base_; + GlobalVariables* globals_; + Callback cancel_server_; - SignalHandler() : _globals(nullptr), _cancel_server(nullptr) {} + SignalHandler() : globals_(nullptr), cancel_server_(nullptr) {} }; // A signal-safe version of fprintf(stderr, ...). diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc index e11e230396b638..4767496f170894 100644 --- a/src/main/cpp/blaze_util_posix.cc +++ b/src/main/cpp/blaze_util_posix.cc @@ -141,23 +141,23 @@ static void handler(int signum) { if (++sigint_count >= 3) { SigPrintf( "\n%s caught third interrupt signal; killed.\n\n", - SignalHandler::Get()._product_name.c_str()); + SignalHandler::Get().GetProductName().c_str()); if (SignalHandler::Get().GetGlobals()->server_pid != -1) { KillServerProcess( SignalHandler::Get().GetGlobals()->server_pid, - SignalHandler::Get()._output_base); + SignalHandler::Get().GetOutputBase()); } _exit(1); } SigPrintf( "\n%s caught interrupt signal; shutting down.\n\n", - SignalHandler::Get()._product_name.c_str()); + SignalHandler::Get().GetProductName().c_str()); SignalHandler::Get().CancelServer(); break; case SIGTERM: SigPrintf( "\n%s caught terminate signal; shutting down.\n\n", - SignalHandler::Get()._product_name.c_str()); + SignalHandler::Get().GetProductName().c_str()); SignalHandler::Get().CancelServer(); break; case SIGPIPE: @@ -178,10 +178,10 @@ void SignalHandler::Install(const string &product_name, const string &output_base, GlobalVariables* globals, SignalHandler::Callback cancel_server) { - _product_name = product_name; - _output_base = output_base; - _globals = globals; - _cancel_server = cancel_server; + product_name_ = product_name; + output_base_ = output_base; + globals_ = globals; + cancel_server_ = cancel_server; // Unblock all signals. sigset_t sigset; diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc index c238613759ea1e..9b0f98afece118 100644 --- a/src/main/cpp/blaze_util_windows.cc +++ b/src/main/cpp/blaze_util_windows.cc @@ -297,17 +297,17 @@ BOOL WINAPI ConsoleCtrlHandler(_In_ DWORD ctrlType) { if (++sigint_count >= 3) { SigPrintf( "\n%s caught third Ctrl+C handler signal; killed.\n\n", - SignalHandler::Get()._product_name.c_str()); + SignalHandler::Get().GetProductName().c_str()); if (SignalHandler::Get().GetGlobals()->server_pid != -1) { KillServerProcess( SignalHandler::Get().GetGlobals()->server_pid, - SignalHandler::Get()._output_base); + SignalHandler::Get().GetOutputBase()); } _exit(1); } SigPrintf( "\n%s Ctrl+C handler; shutting down.\n\n", - SignalHandler::Get()._product_name.c_str()); + SignalHandler::Get().GetProductName().c_str()); SignalHandler::Get().CancelServer(); return TRUE; @@ -322,10 +322,10 @@ void SignalHandler::Install(const string &product_name, const string &output_base, GlobalVariables* globals, SignalHandler::Callback cancel_server) { - _product_name = product_name; - _output_base = output_base; - _globals = globals; - _cancel_server = cancel_server; + product_name_ = product_name; + output_base_ = output_base; + globals_ = globals; + cancel_server_ = cancel_server; ::SetConsoleCtrlHandler(&ConsoleCtrlHandler, TRUE); }