mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Do not handle double SIGTERM as abort
A double SIGTERM, or even worse a SIGINT + SIGTERM combination should not result in an abort, given such a signal really means "die whenever you want" and can only be generated programmatically. If one wants the child to die programmatically, they should use SIGKILL. On the other hand that bashing ctrl-c (i.e. SIGINT) multiple times on the keyboard really means abort.
This commit is contained in:
parent
b32e04db60
commit
20544e1f18
|
@ -24,7 +24,7 @@ namespace
|
|||
std::atomic<sig_atomic_t> gLastSignal(0);
|
||||
std::atomic<int> gSignalCount(0);
|
||||
|
||||
extern "C" auto signal_handler(int signal) -> void
|
||||
extern "C" auto sigint_handler(int signal) -> void
|
||||
{
|
||||
++gSignalCount;
|
||||
gLastSignal = signal;
|
||||
|
@ -33,6 +33,11 @@ namespace
|
|||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" auto sigterm_handler(int signal) -> void
|
||||
{
|
||||
gLastSignal = signal;
|
||||
}
|
||||
}
|
||||
|
||||
namespace fair
|
||||
|
@ -85,8 +90,8 @@ Control::Control(const string& name, const Plugin::Version version, const string
|
|||
if (GetProperty<int>("catch-signals") > 0) {
|
||||
LOG(debug) << "Plugin '" << name << "' is setting up signal handling for SIGINT and SIGTERM";
|
||||
fSignalHandlerThread = thread(&Control::SignalHandler, this);
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGINT, sigint_handler);
|
||||
signal(SIGTERM, sigterm_handler);
|
||||
} else {
|
||||
LOG(warn) << "Signal handling (e.g. Ctrl-C) has been deactivated.";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user