Mercurial > hg > toybox
comparison toys/posix/sh.c @ 696:99ca30ad3d2b
Add rebound support to intercept error_exit() and longjmp instead.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 16 Nov 2012 00:35:46 -0600 |
parents | 786841fdb1e0 |
children | 85e5097c49c1 |
comparison
equal
deleted
inserted
replaced
695:d2dde3d0ef05 | 696:99ca30ad3d2b |
---|---|
291 | 291 |
292 tl = toy_find(cmd->argv[0]); | 292 tl = toy_find(cmd->argv[0]); |
293 // Is this command a builtin that should run in this process? | 293 // Is this command a builtin that should run in this process? |
294 if (tl && (tl->flags & TOYFLAG_NOFORK)) { | 294 if (tl && (tl->flags & TOYFLAG_NOFORK)) { |
295 struct toy_context temp; | 295 struct toy_context temp; |
296 jmp_buf rebound; | |
296 | 297 |
297 // This fakes lots of what toybox_main() does. | 298 // This fakes lots of what toybox_main() does. |
298 memcpy(&temp, &toys, sizeof(struct toy_context)); | 299 memcpy(&temp, &toys, sizeof(struct toy_context)); |
299 memset(&toys, 0, sizeof(struct toy_context)); | 300 memset(&toys, 0, sizeof(struct toy_context)); |
300 toy_init(tl, cmd->argv); | 301 |
301 tl->toy_main(); | 302 if (!setjmp(rebound)) { |
303 toys.rebound = rebound; | |
304 toy_init(tl, cmd->argv); | |
305 tl->toy_main(); | |
306 } | |
302 cmd->pid = toys.exitval; | 307 cmd->pid = toys.exitval; |
303 free(toys.optargs); | 308 free(toys.optargs); |
304 if (toys.old_umask) umask(toys.old_umask); | 309 if (toys.old_umask) umask(toys.old_umask); |
305 memcpy(&toys, &temp, sizeof(struct toy_context)); | 310 memcpy(&toys, &temp, sizeof(struct toy_context)); |
306 } else { | 311 } else { |