Skip to content

Commit

Permalink
Suppress tracebacks when SIGTERM signal processing
Browse files Browse the repository at this point in the history
This is a workaround for
rhinstaller/kickstart-tests#1296

where we are most likely hitting issue that logging is not safe to use
in the signal handlers because logging is not reentrant safe. To avoid
failures in KS tests and also test if this is the correct issue, let's
use this workaround.

The ideal fix should be to not use logging in atexit call which might be
tricky to resolve and also we will use a lot of log outputs.
  • Loading branch information
jkonecny12 committed Oct 16, 2024
1 parent 4683a89 commit 645d5bf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion anaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,18 @@ def setup_environment():
from pyanaconda.anaconda import Anaconda
anaconda = Anaconda()

def terminate(num, frame):
try:
# This will execute atexit function which might fail because of logging exception
# which shouldn't be used in signal handlers. However, it's during the shutdown
# process so let's suppress this to avoid issues.
sys.exit(1)
except Exception as ex:
print("Error raised when terminating Anaconda: \n %s", ex)

# reset python's default SIGINT handler
signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTERM, lambda num, frame: sys.exit(1))
signal.signal(signal.SIGTERM, terminate)

# synchronously-delivered signals such as SIGSEGV and SIGILL cannot be handled properly from
# Python, so install signal handlers from the faulthandler stdlib module.
Expand Down

0 comments on commit 645d5bf

Please sign in to comment.