diff --git a/salt/utils/process.py b/salt/utils/process.py index b0d8da06c9..fba4cff72e 100644 --- a/salt/utils/process.py +++ b/salt/utils/process.py @@ -806,7 +806,7 @@ def default_signals(*signals): old_signals = {} for signum in signals: try: - old_signals[signum] = signal.getsignal(signum) + saved_signal = signal.getsignal(signum) signal.signal(signum, signal.SIG_DFL) except ValueError as exc: # This happens when a netapi module attempts to run a function @@ -816,6 +816,8 @@ def default_signals(*signals): 'Failed to register signal for signum %d: %s', signum, exc ) + else: + old_signals[signum] = saved_signal # Do whatever is needed with the reset signals yield