diff options
| author | Chet Ramey <chet.ramey@case.edu> | 2013-01-03 10:47:42 -0500 |
|---|---|---|
| committer | Chet Ramey <chet.ramey@case.edu> | 2013-01-03 10:47:42 -0500 |
| commit | 36eb585cfa52fbb6cd0c324c628593ea856a50a5 (patch) | |
| tree | a8517ab3cbdc6be0ef631b44386cb4927b691348 /builtins/evalstring.c | |
| parent | 77b3aacbdfa8786847658c972b7cac45e1988c29 (diff) | |
| download | bash-36eb585cfa52fbb6cd0c324c628593ea856a50a5.tar.gz | |
commit bash-20121221 snapshot
Diffstat (limited to 'builtins/evalstring.c')
| -rw-r--r-- | builtins/evalstring.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/builtins/evalstring.c b/builtins/evalstring.c index cb004c4e..a78688cc 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -192,6 +192,7 @@ parse_and_execute (string, from_file, flags) int code, lreset; volatile int should_jump_to_top_level, last_result; COMMAND *volatile command; + volatile sigset_t pe_sigmask; parse_prologue (string, flags, PE_TAG); @@ -199,6 +200,12 @@ parse_and_execute (string, from_file, flags) lreset = flags & SEVAL_RESETLINE; +#if defined (HAVE_POSIX_SIGNALS) + /* If we longjmp and are going to go on, use this to restore signal mask */ + sigemptyset (&pe_sigmask); + sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &pe_sigmask); +#endif + /* Reset the line number if the caller wants us to. If we don't reset the line number, we have to subtract one, because we will add one just before executing the next command (resetting the line number sets it to @@ -226,7 +233,7 @@ parse_and_execute (string, from_file, flags) /* Provide a location for functions which `longjmp (top_level)' to jump to. This prevents errors in substitution from restarting the reader loop directly, for example. */ - code = setjmp (top_level); + code = setjmp_nosigs (top_level); if (code) { @@ -270,6 +277,9 @@ parse_and_execute (string, from_file, flags) #if 0 dispose_command (command); /* pe_dispose does this */ #endif +#if defined (HAVE_POSIX_SIGNALS) + sigprocmask (SIG_SETMASK, &pe_sigmask, (sigset_t *)NULL); +#endif continue; } @@ -407,9 +417,16 @@ parse_string (string, from_file, flags, endp) volatile int should_jump_to_top_level; COMMAND *volatile command, *oglobal; char *ostring; + volatile sigset_t ps_sigmask; parse_prologue (string, flags, PS_TAG); +#if defined (HAVE_POSIX_SIGNALS) + /* If we longjmp and are going to go on, use this to restore signal mask */ + sigemptyset (&ps_sigmask); + sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &ps_sigmask); +#endif + /* Reset the line number if the caller wants us to. If we don't reset the line number, we have to subtract one, because we will add one just before executing the next command (resetting the line number sets it to @@ -432,7 +449,7 @@ parse_string (string, from_file, flags, endp) /* Provide a location for functions which `longjmp (top_level)' to jump to. */ - code = setjmp (top_level); + code = setjmp_nosigs (top_level); if (code) { @@ -454,6 +471,9 @@ itrace("parse_string: longjmp executed: code = %d", code); goto out; default: +#if defined (HAVE_POSIX_SIGNALS) + sigprocmask (SIG_SETMASK, &ps_sigmask, (sigset_t *)NULL); +#endif command_error ("parse_string", CMDERR_BADJUMP, code, 0); break; } @@ -558,7 +578,7 @@ evalstring (string, from_file, flags) unwind_protect_jmp_buf (return_catch); return_catch_flag++; /* increment so we have a counter */ - rcatch = setjmp (return_catch); + rcatch = setjmp_nosigs (return_catch); } if (rcatch) |
