From caf39c26827f355c4e107f55c5c51f67c484bfd7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 16 Nov 2012 00:35:46 -0600 Subject: Add rebound support to intercept error_exit() and longjmp instead. --- toys/posix/sh.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'toys/posix/sh.c') 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); -- cgit v1.2.3