Fix signal lookup to only include singals.

The python signal logic not only contains Singal to int mappings, but
also constants for sigmasks.
This leads to both SIGHUP and SIG_UNBLOCK to map to 1.
In the reverse mapping it is then undefined which of these will then be
taken.

This can lead to strange log messages like
"Caught SIG_UNBLOCK, stopping children".
This is confusing.

Closes-Bug: #2106369
Change-Id: Ife50cdf9415f395a1241a17faeaeca8cb3e6c9a5
Signed-off-by: Felix Huettner <felix.huettner@stackit.cloud>
This commit is contained in:
Felix Huettner
2025-03-20 13:29:39 +01:00
committed by Takashi Kajinami
parent c98feeb23d
commit bfc7798a9f

View File

@@ -38,11 +38,12 @@ def is_sighup_and_daemon(signo, signal_handler):
signo == signal.SIGHUP and is_daemon())
def get_signal_mappings(ignore=('SIG_DFL', 'SIG_IGN')):
def get_signal_mappings():
signals_by_name = {
name: getattr(signal, name)
for name in dir(signal)
if name.startswith('SIG') and name not in ignore
if name.startswith('SIG') and
isinstance(getattr(signal, name), signal.Signals)
}
signals_to_name = {v: k for k, v in signals_by_name.items()}