80 (void) connect(_notifier, &QWinEventNotifier::activated,
this, [
this]([[maybe_unused]] HANDLE handle) {
111 struct sigaction sa{};
112 sa.sa_handler = SIG_DFL;
113 (void) sigaction(SIGINT, &sa,
nullptr);
114 (void) sigaction(SIGTERM, &sa,
nullptr);
117 _notifierInt->setEnabled(
false);
120 _notifierTerm->setEnabled(
false);
123 if (_sigIntFd[0] >= 0) {
124 (void) ::close(_sigIntFd[0]);
127 if (_sigIntFd[1] >= 0) {
128 (void) ::close(_sigIntFd[1]);
131 if (_sigTermFd[0] >= 0) {
132 (void) ::close(_sigTermFd[0]);
135 if (_sigTermFd[1] >= 0) {
136 (void) ::close(_sigTermFd[1]);
140 s_current.store(
nullptr, std::memory_order_release);
141 qCDebug(SignalHandlerLog) <<
this;
147 if (::socketpair(AF_UNIX, SOCK_DGRAM, 0, _sigIntFd)) {
148 qCCritical(SignalHandlerLog) <<
"Failed to create SIGINT socketpair:" << strerror(errno);
151 if (::socketpair(AF_UNIX, SOCK_DGRAM, 0, _sigTermFd)) {
152 qCCritical(SignalHandlerLog) <<
"Failed to create SIGTERM socketpair:" << strerror(errno);
157 (void) fcntl(_sigIntFd[0], F_SETFD, fcntl(_sigIntFd[0], F_GETFD, 0) | FD_CLOEXEC);
158 (void) fcntl(_sigIntFd[1], F_SETFD, fcntl(_sigIntFd[1], F_GETFD, 0) | FD_CLOEXEC);
159 (void) fcntl(_sigTermFd[0], F_SETFD, fcntl(_sigTermFd[0], F_GETFD, 0) | FD_CLOEXEC);
160 (void) fcntl(_sigTermFd[1], F_SETFD, fcntl(_sigTermFd[1], F_GETFD, 0) | FD_CLOEXEC);
163 (void) fcntl(_sigIntFd[0], F_SETFL, fcntl(_sigIntFd[0], F_GETFL, 0) | O_NONBLOCK);
164 (void) fcntl(_sigTermFd[0], F_SETFL, fcntl(_sigTermFd[0], F_GETFL, 0) | O_NONBLOCK);
166 _notifierInt =
new QSocketNotifier(_sigIntFd[0], QSocketNotifier::Read,
this);
167 _notifierTerm =
new QSocketNotifier(_sigTermFd[0], QSocketNotifier::Read,
this);
168 (void) connect(_notifierInt, &QSocketNotifier::activated,
this, &SignalHandler::_onSigInt);
169 (void) connect(_notifierTerm, &QSocketNotifier::activated,
this, &SignalHandler::_onSigTerm);
171 struct sigaction sa_int{};
172 sigemptyset(&sa_int.sa_mask);
174 sa_int.sa_handler = SignalHandler::_intSignalHandler;
175 if (sigaction(SIGINT, &sa_int,
nullptr)) {
179 struct sigaction sa_term{};
180 sigemptyset(&sa_term.sa_mask);
181 sa_term.sa_flags = 0;
182 sa_term.sa_handler = SignalHandler::_termSignalHandler;
183 if (sigaction(SIGTERM, &sa_term,
nullptr)) {