Skip to content
Snippets Groups Projects
Commit 2213a560 authored by Marc-Olivier Andrez's avatar Marc-Olivier Andrez
Browse files

build: fix GCC compilation error because of call of deprecated function `siginterrupt`

Error message:

> main_eventmon.cpp:109:17: error: ‘int siginterrupt(int, int)’ is deprecated: Use sigaction with SA_RESTART instead [-Werror=deprecated-declarations]

The migration from deprecated `siginterrupt(SIGINT, 1)` to `sigaction` is
inspired by the migration done in CPython, see
https://github.com/python/cpython/commit/f9c5e3f5f61cd380f8a17c814766fc3730b7fbdf
parent 8b873b1a
No related branches found
No related tags found
No related merge requests found
......@@ -105,8 +105,18 @@ int main (int argc, char* argv[]) {
stop_signal = 0;
std::signal(SIGINT, SignalHandler);
std::signal(SIGTERM, SignalHandler);
#if defined(__linux__) || defined (__APPLE__)
siginterrupt(SIGINT, 1);
#if defined(__linux__) || defined(__APPLE__)
{
// Sets the flag SA_RESTART of `current_sigaction` to false to prevent SIGINT
// signals to be invoked again after it has been handled.
// The migration from deprecated `siginterrupt(SIGINT, 1)` to `sigaction`
// is inspired by the migration done in CPython, see
// https://github.com/python/cpython/commit/f9c5e3f5f61cd380f8a17c814766fc3730b7fbdf
struct sigaction current_sigaction;
sigaction(SIGINT, NULL, &current_sigaction);
current_sigaction.sa_flags &= ~SA_RESTART;
sigaction(SIGINT, &current_sigaction, NULL);
}
#endif
const auto logger = asapo::GetDefaultEventMonLogger();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment