1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 17:57:59 +00:00

mount: umount on SIGINT/^C when in foreground

This commit is contained in:
Marian Beermann 2017-01-24 14:18:25 +01:00
parent b6191ececc
commit 2cfaf03f84
2 changed files with 10 additions and 1 deletions

View file

@ -1546,6 +1546,13 @@ def build_parser(self, args=None, prog=None):
- allow_damaged_files: by default damaged files (where missing chunks were
replaced with runs of zeros by borg check --repair) are not readable and
return EIO (I/O error). Set this option to read such files.
When the daemonized process receives a signal or crashes, it does not unmount.
Unmounting in these cases could cause an active rsync or similar process
to unintentionally delete data.
When running in the foreground ^C/SIGINT unmounts cleanly, but other
signals or crashes do not.
""")
subparser = subparsers.add_parser('mount', parents=[common_parser],
description=self.do_mount.__doc__,

View file

@ -6,6 +6,7 @@
import stat
import tempfile
import time
from signal import SIGINT
from distutils.version import LooseVersion
import msgpack
@ -98,7 +99,8 @@ def mount(self, mountpoint, mount_options, foreground=False):
umount = False
try:
signal = fuse_main()
umount = (signal is None) # no crash and no signal -> umount request
# no crash and no signal (or it's ^C and we're in the foreground) -> umount request
umount = (signal is None or (signal == SIGINT and foreground))
finally:
llfuse.close(umount)