Skip to content

Commit 806a048

Browse files
committed
Fixed SIGINT/SIGTERM handler
Each signal need to be registered separately.
1 parent c5e4fe3 commit 806a048

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ int main(int argc, const char* argv[]) noexcept {
240240
sigIntHandler.sa_handler = sigint_handler;
241241
sigemptyset(&sigIntHandler.sa_mask);
242242
sigIntHandler.sa_flags = 0;
243-
sigaction(SIGINT | SIGTERM, &sigIntHandler, nullptr);
243+
if (sigaction(SIGINT, &sigIntHandler, nullptr) != 0) {
244+
zit::logger()->warn("Error: Failed to set SIGINT handler.");
245+
}
246+
if (sigaction(SIGTERM, &sigIntHandler, nullptr) != 0) {
247+
zit::logger()->warn("Error: Failed to set SIGTERM handler.");
248+
}
244249
// NOLINTEND(cppcoreguidelines-pro-type-union-access,misc-include-cleaner)
245250
#endif // !WIN32
246251

0 commit comments

Comments
 (0)