diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-08 16:47:31 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-08 16:47:31 +0100 |
commit | 54ccac82994b62378b1895782481d437565e9999 (patch) | |
tree | 9e772cbbf22ff487dbce1d82f21bed142aea4e82 | |
parent | b2e9c4a40bb11bfb7e5eceb7cb3aa387c2d57a59 (diff) | |
download | nixos-54ccac82994b62378b1895782481d437565e9999.tar nixos-54ccac82994b62378b1895782481d437565e9999.tar.gz nixos-54ccac82994b62378b1895782481d437565e9999.tar.bz2 nixos-54ccac82994b62378b1895782481d437565e9999.tar.xz nixos-54ccac82994b62378b1895782481d437565e9999.zip |
ymir: ...
-rwxr-xr-x | snap.py | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -16,6 +16,14 @@ import unshare | |||
16 | import signal | 16 | import signal |
17 | 17 | ||
18 | 18 | ||
19 | children = set() | ||
20 | |||
21 | def waitchildren(): | ||
22 | while children: | ||
23 | waitpid, waitret = os.wait() | ||
24 | children.remove(waitpid) | ||
25 | |||
26 | |||
19 | def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args): | 27 | def 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 | ||
95 | def sigterm(signum, frame): | 100 | def sigterm(signum, frame): |