diff options
author | Jürg Billeter <j@bitron.ch> | 2018-02-16 11:15:18 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-02-24 11:03:37 +0000 |
commit | 1476e43633b0798a013c46e740271bdd0ce9187d (patch) | |
tree | c1c6d2c9d7b855de70d083bf4a1f471b64b34dd7 /buildstream/_platform/linux.py | |
parent | 34bf8a0d74af03fbf68e96259e09815d0b48b622 (diff) | |
download | buildstream-1476e43633b0798a013c46e740271bdd0ce9187d.tar.gz |
sandbox/_sandboxbwrap.py: Use --die-with-parent
This ensures subprocesses are cleaned up when the bwrap parent dies.
This is available since bubblewrap 0.1.8. We skip the option if the host
bwrap does not support it.
Diffstat (limited to 'buildstream/_platform/linux.py')
-rw-r--r-- | buildstream/_platform/linux.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py index c180cc60a..9a2bcd356 100644 --- a/buildstream/_platform/linux.py +++ b/buildstream/_platform/linux.py @@ -36,6 +36,9 @@ class Linux(Platform): self._user_ns_available = False self.check_user_ns_available(context) + + self.check_die_with_parent_available(context) + self._artifact_cache = OSTreeCache(context, enable_push=self._user_ns_available) def check_user_ns_available(self, context): @@ -69,6 +72,23 @@ class Linux(Platform): detail="Some builds may not function due to lack of uid / gid 0, " + "artifacts created will not be trusted for push purposes.")) + def check_die_with_parent_available(self, context): + + # bwrap supports --die-with-parent since 0.1.8. + # Let's check whether the host bwrap supports it. + bwrap = utils.get_host_tool('bwrap') + + try: + subprocess.check_call([ + bwrap, + '--ro-bind', '/', '/', + '--die-with-parent', + 'true' + ], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + self._die_with_parent_available = True + except subprocess.CalledProcessError: + self._die_with_parent_available = False + @property def artifactcache(self): return self._artifact_cache @@ -76,4 +96,5 @@ class Linux(Platform): def create_sandbox(self, *args, **kwargs): # Inform the bubblewrap sandbox as to whether it can use user namespaces or not kwargs['user_ns_available'] = self._user_ns_available + kwargs['die_with_parent_available'] = self._die_with_parent_available return SandboxBwrap(*args, **kwargs) |