Passing the Unix SIGTERM signal through to child processes like Borg.

This commit is contained in:
Dan
2017-10-31 21:58:35 -07:00
parent 95be0c8e46
commit 27a6745743
4 changed files with 24 additions and 1 deletions

17
borgmatic/signals.py Normal file
View File

@@ -0,0 +1,17 @@
import os
import signal
def _handle_signal(signal_number, frame):
'''
Send the signal to all processes in borgmatic's process group, which includes child process.
'''
os.killpg(os.getpgrp(), signal_number)
def configure_signals():
'''
Configure borgmatic's signal handlers to pass relevant signals through to any child processes
like Borg.
'''
signal.signal(signal.SIGTERM, _handle_signal)