summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-02-08 16:47:31 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-02-08 16:47:31 +0100
commit54ccac82994b62378b1895782481d437565e9999 (patch)
tree9e772cbbf22ff487dbce1d82f21bed142aea4e82
parentb2e9c4a40bb11bfb7e5eceb7cb3aa387c2d57a59 (diff)
downloadnixos-54ccac82994b62378b1895782481d437565e9999.tar
nixos-54ccac82994b62378b1895782481d437565e9999.tar.gz
nixos-54ccac82994b62378b1895782481d437565e9999.tar.bz2
nixos-54ccac82994b62378b1895782481d437565e9999.tar.xz
nixos-54ccac82994b62378b1895782481d437565e9999.zip
ymir: ...
-rwxr-xr-xsnap.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/snap.py b/snap.py
index 3d9c315a..0c22fc44 100755
--- a/snap.py
+++ b/snap.py
@@ -16,6 +16,14 @@ import unshare
16import signal 16import signal
17 17
18 18
19children = set()
20
21def waitchildren():
22 while children:
23 waitpid, waitret = os.wait()
24 children.remove(waitpid)
25
26
19def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args): 27def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args):
20 vgp = lv.split('/') 28 vgp = lv.split('/')
21 lvn = vgp[-1] 29 lvn = vgp[-1]
@@ -83,13 +91,10 @@ def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args):
83 91
84 os._exit(0) 92 os._exit(0)
85 else: 93 else:
86 while True: 94 children.add(child)
87 waitpid, waitret = os.wait() 95 waitchildren()
88 if waitret != 0:
89 sys.exit(waitret)
90 if waitpid == child:
91 break
92 finally: 96 finally:
97 waitchildren()
93 subprocess.run(['lvremove', '--force', sn], stdin=subprocess.DEVNULL, check=True) 98 subprocess.run(['lvremove', '--force', sn], stdin=subprocess.DEVNULL, check=True)
94 99
95def sigterm(signum, frame): 100def sigterm(signum, frame):