diff options
author | jilles <jilles@FreeBSD.org> | 2009-12-25 20:21:35 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2009-12-25 20:21:35 +0000 |
commit | 545cc5fec7115d450d5b76c2f598d1eafb16d592 (patch) | |
tree | 70cc7efa48eb3f1089f61e3030e19359262db521 /bin/sh/main.c | |
parent | 2f4287b1338caa52535b49c6af74ecf62ecdb8ed (diff) | |
download | FreeBSD-src-545cc5fec7115d450d5b76c2f598d1eafb16d592.zip FreeBSD-src-545cc5fec7115d450d5b76c2f598d1eafb16d592.tar.gz |
sh: Do not run callers' exception handlers in subshells.
Reset the exception handler in the child to main's.
This avoids inappropriate double cleanups or shell duplication when the
exception is caught, such as 'fc' and future 'command eval' and 'command .'.
Diffstat (limited to 'bin/sh/main.c')
-rw-r--r-- | bin/sh/main.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bin/sh/main.c b/bin/sh/main.c index 547aad9..c21e8df 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); int rootpid; int rootshell; +struct jmploc main_handler; STATIC void read_profile(char *); STATIC char *find_dot_file(char *); @@ -90,14 +91,13 @@ STATIC char *find_dot_file(char *); int main(int argc, char *argv[]) { - struct jmploc jmploc; struct stackmark smark; volatile int state; char *shinit; (void) setlocale(LC_ALL, ""); state = 0; - if (setjmp(jmploc.loc)) { + if (setjmp(main_handler.loc)) { /* * When a shell procedure is executed, we raise the * exception EXSHELLPROC to clean up before executing @@ -143,7 +143,7 @@ main(int argc, char *argv[]) else goto state4; } - handler = &jmploc; + handler = &main_handler; #ifdef DEBUG opentrace(); trputs("Shell args: "); trargs(argv); |