aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-16 00:35:46 -0600
committerRob Landley <rob@landley.net>2012-11-16 00:35:46 -0600
commitcaf39c26827f355c4e107f55c5c51f67c484bfd7 (patch)
tree718852f37b7143cb63e6e8838093993b19391a39 /toys/posix
parent02261e8082b9b098b20a4291fc2583f3c41db8d2 (diff)
downloadtoybox-caf39c26827f355c4e107f55c5c51f67c484bfd7.tar.gz
Add rebound support to intercept error_exit() and longjmp instead.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/sh.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/toys/posix/sh.c b/toys/posix/sh.c
index 30900b30..32d05ec2 100644
--- a/toys/posix/sh.c
+++ b/toys/posix/sh.c
@@ -293,12 +293,17 @@ static void run_pipeline(struct pipeline *line)
// Is this command a builtin that should run in this process?
if (tl && (tl->flags & TOYFLAG_NOFORK)) {
struct toy_context temp;
+ jmp_buf rebound;
// This fakes lots of what toybox_main() does.
memcpy(&temp, &toys, sizeof(struct toy_context));
memset(&toys, 0, sizeof(struct toy_context));
- toy_init(tl, cmd->argv);
- tl->toy_main();
+
+ if (!setjmp(rebound)) {
+ toys.rebound = rebound;
+ toy_init(tl, cmd->argv);
+ tl->toy_main();
+ }
cmd->pid = toys.exitval;
free(toys.optargs);
if (toys.old_umask) umask(toys.old_umask);