diff options
author | Rob Landley <rob@landley.net> | 2012-11-16 00:35:46 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-11-16 00:35:46 -0600 |
commit | caf39c26827f355c4e107f55c5c51f67c484bfd7 (patch) | |
tree | 718852f37b7143cb63e6e8838093993b19391a39 /toys | |
parent | 02261e8082b9b098b20a4291fc2583f3c41db8d2 (diff) | |
download | toybox-caf39c26827f355c4e107f55c5c51f67c484bfd7.tar.gz |
Add rebound support to intercept error_exit() and longjmp instead.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/lsb/killall.c | 2 | ||||
-rw-r--r-- | toys/posix/sh.c | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c index 7883c53d..debc3dfc 100644 --- a/toys/lsb/killall.c +++ b/toys/lsb/killall.c @@ -48,7 +48,7 @@ void killall_main(void) toys.exitval++; if (!*toys.optargs) { - toys.exithelp = 1; + toys.exithelp++; error_exit("Process name missing!"); } 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); |