summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gi/_ossighelper.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/gi/_ossighelper.py b/gi/_ossighelper.py
index 5176e97c..213f0965 100644
--- a/gi/_ossighelper.py
+++ b/gi/_ossighelper.py
@@ -224,8 +224,9 @@ def register_sigint_fallback(callback):
try:
yield
finally:
+ cb = _callback_stack.pop()
if _sigint_called:
- _callback_stack.pop()()
+ cb()
else:
# There is a signal handler set by the user, just do nothing
yield
@@ -242,9 +243,11 @@ def register_sigint_fallback(callback):
_callback_stack.pop()()
_callback_stack.append(callback)
- with sigint_handler_set_and_restore_default(sigint_handler):
- try:
+ try:
+ with sigint_handler_set_and_restore_default(sigint_handler):
yield
- finally:
- if _sigint_called:
- signal.default_int_handler(signal.SIGINT, None)
+ finally:
+ if _sigint_called:
+ signal.default_int_handler(signal.SIGINT, None)
+ else:
+ _callback_stack.pop()