Skip to content

Commit 52514eb

Browse files
authored
make calling the original signal handler better
1 parent 58c74a8 commit 52514eb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

dirlock/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def handle_sigint_cleanup(signum, frame):
4444
global original_sigint_handler
4545
_clean_locks()
4646
if original_sigint_handler is not None:
47-
original_sigint_handler(signum, frame)
47+
# restore the original handler
48+
signal.signal(signal.SIGINT, original_sigint_handler)
49+
# and re-raise the signal
50+
os.kill(os.getpid(), signal.SIGINT)
4851

4952

5053
def handle_sigterm_cleanup(signum, frame):
@@ -56,7 +59,10 @@ def handle_sigterm_cleanup(signum, frame):
5659
global original_sigterm_handler
5760
_clean_locks()
5861
if original_sigterm_handler is not None:
59-
original_sigterm_handler(signum, frame)
62+
# restore the original handler
63+
signal.signal(signal.SIGTERM, original_sigterm_handler)
64+
# and re-raise the signal
65+
os.kill(os.getpid(), signal.SIGTERM)
6066

6167

6268
# normal exit clean up

0 commit comments

Comments
 (0)