Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress tracebacks when SIGTERM signal processing #5939

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion anaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def exitHandler(rebootData):
else: # reboot action is KS_REBOOT or None
util.execWithRedirect("systemctl", ["--no-wall", "reboot"], do_preexec=False)

print("End of atexit!", file=sys.stderr)


def parse_arguments(argv=None, boot_cmdline=None):
"""Parse command line/boot options and arguments.
Expand Down Expand Up @@ -289,9 +291,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, file=sys.stderr)

# 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
Loading