mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 09:47:58 +00:00
commit
eaf0f62022
1 changed files with 12 additions and 0 deletions
|
@ -1488,6 +1488,14 @@ def sig_info_handler(signum, stack): # pragma: no cover
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
class SIGTERMReceived(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def sig_term_handler(signum, stack):
|
||||||
|
raise SIGTERMReceived
|
||||||
|
|
||||||
|
|
||||||
def setup_signal_handlers(): # pragma: no cover
|
def setup_signal_handlers(): # pragma: no cover
|
||||||
sigs = []
|
sigs = []
|
||||||
if hasattr(signal, 'SIGUSR1'):
|
if hasattr(signal, 'SIGUSR1'):
|
||||||
|
@ -1496,6 +1504,7 @@ def setup_signal_handlers(): # pragma: no cover
|
||||||
sigs.append(signal.SIGINFO) # kill -INFO pid (or ctrl-t)
|
sigs.append(signal.SIGINFO) # kill -INFO pid (or ctrl-t)
|
||||||
for sig in sigs:
|
for sig in sigs:
|
||||||
signal.signal(sig, sig_info_handler)
|
signal.signal(sig, sig_info_handler)
|
||||||
|
signal.signal(signal.SIGTERM, sig_term_handler)
|
||||||
|
|
||||||
|
|
||||||
def main(): # pragma: no cover
|
def main(): # pragma: no cover
|
||||||
|
@ -1523,6 +1532,9 @@ def main(): # pragma: no cover
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
msg = 'Keyboard interrupt.\n%s\n%s' % (traceback.format_exc(), sysinfo())
|
msg = 'Keyboard interrupt.\n%s\n%s' % (traceback.format_exc(), sysinfo())
|
||||||
exit_code = EXIT_ERROR
|
exit_code = EXIT_ERROR
|
||||||
|
except SIGTERMReceived:
|
||||||
|
msg = 'Received SIGTERM.'
|
||||||
|
exit_code = EXIT_ERROR
|
||||||
if msg:
|
if msg:
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
if args.show_rc:
|
if args.show_rc:
|
||||||
|
|
Loading…
Reference in a new issue