From 54ccac82994b62378b1895782481d437565e9999 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 8 Feb 2022 16:47:31 +0100 Subject: ymir: ... --- snap.py | 17 +++++++++++------ 1 file 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 import signal +children = set() + +def waitchildren(): + while children: + waitpid, waitret = os.wait() + children.remove(waitpid) + + def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args): vgp = lv.split('/') lvn = vgp[-1] @@ -83,13 +91,10 @@ def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args): os._exit(0) else: - while True: - waitpid, waitret = os.wait() - if waitret != 0: - sys.exit(waitret) - if waitpid == child: - break + children.add(child) + waitchildren() finally: + waitchildren() subprocess.run(['lvremove', '--force', sn], stdin=subprocess.DEVNULL, check=True) def sigterm(signum, frame): -- cgit v1.2.3