Defines a signal handler for win32 and *nix.
More...
#include <util.h>
|
| template<typename T> |
| static bool | install (T t) |
| | installs a signal handler
|
Defines a signal handler for win32 and *nix.
Definition at line 159 of file util.h.
◆ install()
| bool tools::signal_handler::install |
( |
T | t | ) |
|
|
inlinestatic |
installs a signal handler
Definition at line 164 of file util.h.
165 {
166#if defined(WIN32)
167 bool r = TRUE == ::SetConsoleCtrlHandler(&win_handler, TRUE);
168 if (r)
169 {
170 m_handler = t;
171 }
172 return r;
173#else
174 static struct sigaction sa;
175 memset(&sa, 0, sizeof(struct sigaction));
176 sa.sa_handler = posix_handler;
177 sa.sa_flags = 0;
178
179 sigaction(SIGINT, &sa, NULL);
180 signal(SIGTERM, posix_handler);
181 signal(SIGPIPE, SIG_IGN);
182 m_handler = t;
183 return true;
184#endif
185 }
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/common/util.h
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/common/util.cpp