aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/interrupt_signals.cpp
diff options
context:
space:
mode:
authorakhropov <akhropov@yandex-team.ru>2022-02-10 16:46:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:32 +0300
commit00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (patch)
treecb7a9f4a92c0d4cc5a86eeed49ad71e810953c1f /util/system/interrupt_signals.cpp
parent83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (diff)
downloadydb-00afc96e9c0298054b7386fa7fb9e3cc3d67b974.tar.gz
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/interrupt_signals.cpp')
-rw-r--r--util/system/interrupt_signals.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/util/system/interrupt_signals.cpp b/util/system/interrupt_signals.cpp
index 96b723f2b8..61ff8dd720 100644
--- a/util/system/interrupt_signals.cpp
+++ b/util/system/interrupt_signals.cpp
@@ -1,60 +1,60 @@
-#include "interrupt_signals.h"
-
-#include "compiler.h"
-#include "error.h"
-
-#include <util/generic/yexception.h>
-
-#include <csignal>
-
-static void (*InterruptSignalsHandler)(int signum) = nullptr;
-
-#ifdef _win_
-
+#include "interrupt_signals.h"
+
+#include "compiler.h"
+#include "error.h"
+
+#include <util/generic/yexception.h>
+
+#include <csignal>
+
+static void (*InterruptSignalsHandler)(int signum) = nullptr;
+
+#ifdef _win_
+
#include <windows.h>
-
-static BOOL WINAPI WindowsSignalsHandler(_In_ DWORD dwCtrlType) {
- if (!InterruptSignalsHandler) {
- return FALSE;
- }
-
- switch (dwCtrlType) {
- case CTRL_C_EVENT:
- InterruptSignalsHandler(SIGINT);
- return TRUE;
- case CTRL_BREAK_EVENT:
- InterruptSignalsHandler(SIGTERM);
- return TRUE;
- case CTRL_CLOSE_EVENT:
- InterruptSignalsHandler(SIGHUP);
- return TRUE;
- default:
- return FALSE;
- }
- Y_UNREACHABLE();
-}
-
-#endif
-
-// separate function is to enforce 'extern "C"' linkage
-extern "C" void CppSignalsHandler(int signum) {
- if (InterruptSignalsHandler) {
- InterruptSignalsHandler(signum);
- }
-}
-
-void SetInterruptSignalsHandler(void (*handler)(int signum)) {
- InterruptSignalsHandler = handler;
-#ifdef _win_
- if (!SetConsoleCtrlHandler(WindowsSignalsHandler, TRUE)) {
- ythrow TSystemError() << "SetConsoleCtrlHandler failed: " << LastSystemErrorText();
- }
- for (int signum : {SIGINT, SIGTERM}) {
-#else
- for (int signum : {SIGINT, SIGTERM, SIGHUP}) {
-#endif
- if (std::signal(signum, CppSignalsHandler) == SIG_ERR) {
- ythrow TSystemError() << "std::signal failed to set handler for signal with id " << signum;
- }
- }
-}
+
+static BOOL WINAPI WindowsSignalsHandler(_In_ DWORD dwCtrlType) {
+ if (!InterruptSignalsHandler) {
+ return FALSE;
+ }
+
+ switch (dwCtrlType) {
+ case CTRL_C_EVENT:
+ InterruptSignalsHandler(SIGINT);
+ return TRUE;
+ case CTRL_BREAK_EVENT:
+ InterruptSignalsHandler(SIGTERM);
+ return TRUE;
+ case CTRL_CLOSE_EVENT:
+ InterruptSignalsHandler(SIGHUP);
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ Y_UNREACHABLE();
+}
+
+#endif
+
+// separate function is to enforce 'extern "C"' linkage
+extern "C" void CppSignalsHandler(int signum) {
+ if (InterruptSignalsHandler) {
+ InterruptSignalsHandler(signum);
+ }
+}
+
+void SetInterruptSignalsHandler(void (*handler)(int signum)) {
+ InterruptSignalsHandler = handler;
+#ifdef _win_
+ if (!SetConsoleCtrlHandler(WindowsSignalsHandler, TRUE)) {
+ ythrow TSystemError() << "SetConsoleCtrlHandler failed: " << LastSystemErrorText();
+ }
+ for (int signum : {SIGINT, SIGTERM}) {
+#else
+ for (int signum : {SIGINT, SIGTERM, SIGHUP}) {
+#endif
+ if (std::signal(signum, CppSignalsHandler) == SIG_ERR) {
+ ythrow TSystemError() << "std::signal failed to set handler for signal with id " << signum;
+ }
+ }
+}