summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2016-06-11 17:38:59 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2016-06-11 17:38:59 +0900
commit5206439e606f95a831a216e8fd8ba5c97cfbd401 (patch)
tree242f0d405c53cdb9bf2cdf68e6d9a35cdbc4160c
parenta9198d361f0b1ea7a09cc7006eb3ffec49cb4363 (diff)
downloadsandboxlib-5206439e606f95a831a216e8fd8ba5c97cfbd401.tar.gz
Propagate child process traceback from chroot process.
Without propagating the traceback for the child, issues such as the following become near impossible to diagnose: https://github.com/devcurmudgeon/ybd/issues/224
-rw-r--r--sandboxlib/chroot.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/sandboxlib/chroot.py b/sandboxlib/chroot.py
index 9724368..41fd4de 100644
--- a/sandboxlib/chroot.py
+++ b/sandboxlib/chroot.py
@@ -38,6 +38,7 @@ import multiprocessing
import os
import subprocess
import warnings
+import traceback
import sandboxlib
@@ -195,7 +196,8 @@ def run_command_in_chroot(pipe, stdout, stderr, extra_mounts, chroot_path,
pipe.send([exit, out, err])
result = 0
except Exception as e:
- pipe.send(e)
+ tb = traceback.format_exc()
+ pipe.send((e, tb))
result = 1
os._exit(result)
@@ -228,11 +230,9 @@ def run_sandbox(command, cwd=None, env=None,
exit, out, err = pipe_parent.recv()
return exit, out, err
else:
- # Note that no effort is made to pass on the original traceback, which
- # will be within the _run_command_in_chroot() function somewhere.
- exception = pipe_parent.recv()
- raise exception
-
+ # Report a new exception including the traceback from the child process
+ exception, tb = pipe_parent.recv()
+ raise Exception ('Received exception from chroot, child process traceback:\n%s\n' % tb)
def run_sandbox_with_redirection(command, **sandbox_config):
exit, out, err = run_sandbox(command, **sandbox_config)