diff options
author | Sam Thursfield <ssssam@gmail.com> | 2016-06-11 12:44:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-11 12:44:54 +0100 |
commit | e355e2473b5709f84683471895936e261994b7a7 (patch) | |
tree | 242f0d405c53cdb9bf2cdf68e6d9a35cdbc4160c | |
parent | a9198d361f0b1ea7a09cc7006eb3ffec49cb4363 (diff) | |
parent | 5206439e606f95a831a216e8fd8ba5c97cfbd401 (diff) | |
download | sandboxlib-e355e2473b5709f84683471895936e261994b7a7.tar.gz |
Merge pull request #18 from gtristan/chroot-exception-propagation
Propagate child process traceback from chroot process.
-rw-r--r-- | sandboxlib/chroot.py | 12 |
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) |