borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
10.96k stars 740 forks source link

Killed as a python subprocess leaves lock behind #1591

Closed dragetd closed 8 years ago

dragetd commented 8 years ago

Following example start.py:

import subprocess subprocess.check_call(("borg", "init", "--encryption=none", "/tmp/test")) subprocess.check_call(("borg", "create", "-p", "--verbose", "/tmp/test::archive", "/"))

Start it:

python start.py

Then kill with 'ctrl+c'

borg list /tmp/test Failed to create/acquire the lock /tmp/test/lock.exclusive (timeout).

This method of calling is used by borgmatic. Is this the intended behavior? Should borgmatic take care of quiting borg correctly?

borg-1.0.7

enkore commented 8 years ago

Version?

Since 1.0.3 (iirc) SIGTERM is handled correctly. Things like SIGKILL, on the other hand, cannot be handled. That would be the domain of things like #1246

dragetd commented 8 years ago

Ops, forgot to mention that the script is killed by ctrl+c, sorry. A pretty important detail. Updated the first post accordingly. x.x

So I guess when the script calls borg with check_call, borg gets a SIGKILL when the script is terminated. This means borgmatic needs and update there.