Loading cmds/statsd/src/main.cpp +13 −6 Original line number Diff line number Diff line Loading @@ -38,20 +38,27 @@ using std::make_shared; shared_ptr<StatsService> gStatsService = nullptr; void sigHandler(int sig) { if (gStatsService != nullptr) { gStatsService->Terminate(); void signalHandler(int sig) { if (sig == SIGPIPE) { // ShellSubscriber uses SIGPIPE as a signal to detect the end of the // client process. Don't prematurely exit(1) here. Instead, ignore the // signal and allow the write call to return EPIPE. ALOGI("statsd received SIGPIPE. Ignoring signal."); return; } if (gStatsService != nullptr) gStatsService->Terminate(); ALOGW("statsd terminated on receiving signal %d.", sig); exit(1); } void registerSigHandler() void registerSignalHandlers() { struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = sigHandler; sa.sa_handler = signalHandler; sigaction(SIGPIPE, &sa, nullptr); sigaction(SIGHUP, &sa, nullptr); sigaction(SIGINT, &sa, nullptr); sigaction(SIGQUIT, &sa, nullptr); Loading Loading @@ -79,7 +86,7 @@ int main(int /*argc*/, char** /*argv*/) { return -1; } registerSigHandler(); registerSignalHandlers(); gStatsService->sayHiToStatsCompanion(); Loading Loading
cmds/statsd/src/main.cpp +13 −6 Original line number Diff line number Diff line Loading @@ -38,20 +38,27 @@ using std::make_shared; shared_ptr<StatsService> gStatsService = nullptr; void sigHandler(int sig) { if (gStatsService != nullptr) { gStatsService->Terminate(); void signalHandler(int sig) { if (sig == SIGPIPE) { // ShellSubscriber uses SIGPIPE as a signal to detect the end of the // client process. Don't prematurely exit(1) here. Instead, ignore the // signal and allow the write call to return EPIPE. ALOGI("statsd received SIGPIPE. Ignoring signal."); return; } if (gStatsService != nullptr) gStatsService->Terminate(); ALOGW("statsd terminated on receiving signal %d.", sig); exit(1); } void registerSigHandler() void registerSignalHandlers() { struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = sigHandler; sa.sa_handler = signalHandler; sigaction(SIGPIPE, &sa, nullptr); sigaction(SIGHUP, &sa, nullptr); sigaction(SIGINT, &sa, nullptr); sigaction(SIGQUIT, &sa, nullptr); Loading Loading @@ -79,7 +86,7 @@ int main(int /*argc*/, char** /*argv*/) { return -1; } registerSigHandler(); registerSignalHandlers(); gStatsService->sayHiToStatsCompanion(); Loading