mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-31 21:53:01 +02:00
When ctrl-C is pressed, ensure Borg actually exits (#1015).
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
using an environment variable.
|
||||
* #1013: Send database passwords to MongoDB via anonymous pipe, which is more secure than using
|
||||
"--password" on the command-line.
|
||||
* #1015: When ctrl-C is pressed, ensure Borg actually exits.
|
||||
* Add a "verify_tls" option to the Uptime Kuma monitoring hook for disabling TLS verification.
|
||||
|
||||
1.9.12
|
||||
|
||||
@@ -24,6 +24,9 @@ def handle_signal(signal_number, frame):
|
||||
logger.critical('Exiting due to TERM signal')
|
||||
sys.exit(EXIT_CODE_FROM_SIGNAL + signal.SIGTERM)
|
||||
elif signal_number == signal.SIGINT:
|
||||
# Borg doesn't always exit on a SIGINT, so give it a little encouragement.
|
||||
os.killpg(os.getpgrp(), signal.SIGTERM)
|
||||
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ def test_handle_signal_bails_on_recursion():
|
||||
def test_handle_signal_exits_on_sigterm():
|
||||
signal_number = module.signal.SIGTERM
|
||||
frame = flexmock(f_back=flexmock(f_code=flexmock(co_name='something')))
|
||||
flexmock(module.os).should_receive('getpgrp').and_return(flexmock)
|
||||
flexmock(module.os).should_receive('getpgrp').and_return(flexmock())
|
||||
flexmock(module.os).should_receive('killpg')
|
||||
flexmock(module.sys).should_receive('exit').with_args(
|
||||
module.EXIT_CODE_FROM_SIGNAL + signal_number
|
||||
@@ -38,8 +38,10 @@ def test_handle_signal_exits_on_sigterm():
|
||||
def test_handle_signal_raises_on_sigint():
|
||||
signal_number = module.signal.SIGINT
|
||||
frame = flexmock(f_back=flexmock(f_code=flexmock(co_name='something')))
|
||||
flexmock(module.os).should_receive('getpgrp').and_return(flexmock)
|
||||
flexmock(module.os).should_receive('killpg')
|
||||
process_group = flexmock()
|
||||
flexmock(module.os).should_receive('getpgrp').and_return(process_group)
|
||||
flexmock(module.os).should_receive('killpg').with_args(process_group, module.signal.SIGINT)
|
||||
flexmock(module.os).should_receive('killpg').with_args(process_group, module.signal.SIGTERM)
|
||||
flexmock(module.sys).should_receive('exit').never()
|
||||
|
||||
with pytest.raises(KeyboardInterrupt):
|
||||
|
||||
Reference in New Issue
Block a user