aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-03-19 03:36:18 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-03-19 03:36:18 +0000
commit7f88e34e1a19fca5eb29f5cfb57c54f1ecd5c4a9 (patch)
tree2c7526cdc1fba1c9f5a6380443b21e69e84d05d4
parent5981ba5843ee0696c3fc7ecc192ff09e63e848f8 (diff)
downloadbusybox-w32-7f88e34e1a19fca5eb29f5cfb57c54f1ecd5c4a9.tar.gz
busybox-w32-7f88e34e1a19fca5eb29f5cfb57c54f1ecd5c4a9.tar.bz2
busybox-w32-7f88e34e1a19fca5eb29f5cfb57c54f1ecd5c4a9.zip
ash: tentatively fix bug 189.
-rw-r--r--shell/ash.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 179d9257b..f93d73735 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -165,7 +165,7 @@ struct globals_misc {
165 volatile /*sig_atomic_t*/ smallint intpending; /* 1 = got SIGINT */ 165 volatile /*sig_atomic_t*/ smallint intpending; /* 1 = got SIGINT */
166 /* last pending signal */ 166 /* last pending signal */
167 volatile /*sig_atomic_t*/ smallint pendingsig; 167 volatile /*sig_atomic_t*/ smallint pendingsig;
168 smallint exception; /* kind of exception (0..5) */ 168 smallint exception_type; /* kind of exception (0..5) */
169 /* exceptions */ 169 /* exceptions */
170#define EXINT 0 /* SIGINT received */ 170#define EXINT 0 /* SIGINT received */
171#define EXERROR 1 /* a generic error */ 171#define EXERROR 1 /* a generic error */
@@ -231,7 +231,7 @@ extern struct globals_misc *const ash_ptr_to_globals_misc;
231#define physdir (G_misc.physdir ) 231#define physdir (G_misc.physdir )
232#define arg0 (G_misc.arg0 ) 232#define arg0 (G_misc.arg0 )
233#define exception_handler (G_misc.exception_handler) 233#define exception_handler (G_misc.exception_handler)
234#define exception (G_misc.exception ) 234#define exception_type (G_misc.exception_type )
235#define suppressint (G_misc.suppressint ) 235#define suppressint (G_misc.suppressint )
236#define intpending (G_misc.intpending ) 236#define intpending (G_misc.intpending )
237//#define exsig (G_misc.exsig ) 237//#define exsig (G_misc.exsig )
@@ -290,7 +290,7 @@ raise_exception(int e)
290 abort(); 290 abort();
291#endif 291#endif
292 INT_OFF; 292 INT_OFF;
293 exception = e; 293 exception_type = e;
294 longjmp(exception_handler->loc, 1); 294 longjmp(exception_handler->loc, 1);
295} 295}
296 296
@@ -385,7 +385,6 @@ static void
385onsig(int signo) 385onsig(int signo)
386{ 386{
387 gotsig[signo - 1] = 1; 387 gotsig[signo - 1] = 1;
388 pendingsig = signo;
389 388
390 if (/* exsig || */ (signo == SIGINT && !trap[SIGINT])) { 389 if (/* exsig || */ (signo == SIGINT && !trap[SIGINT])) {
391 if (!suppressint) { 390 if (!suppressint) {
@@ -393,6 +392,8 @@ onsig(int signo)
393 raise_interrupt(); /* does not return */ 392 raise_interrupt(); /* does not return */
394 } 393 }
395 intpending = 1; 394 intpending = 1;
395 } else {
396 pendingsig = signo;
396 } 397 }
397} 398}
398 399
@@ -5199,7 +5200,7 @@ redirectsafe(union node *redir, int flags)
5199 redirect(redir, flags); 5200 redirect(redir, flags);
5200 } 5201 }
5201 exception_handler = savehandler; 5202 exception_handler = savehandler;
5202 if (err && exception != EXERROR) 5203 if (err && exception_type != EXERROR)
5203 longjmp(exception_handler->loc, 1); 5204 longjmp(exception_handler->loc, 1);
5204 RESTORE_INT(saveint); 5205 RESTORE_INT(saveint);
5205 return err; 5206 return err;
@@ -7979,7 +7980,6 @@ static void prehash(union node *);
7979static void 7980static void
7980evaltree(union node *n, int flags) 7981evaltree(union node *n, int flags)
7981{ 7982{
7982
7983 struct jmploc *volatile savehandler = exception_handler; 7983 struct jmploc *volatile savehandler = exception_handler;
7984 struct jmploc jmploc; 7984 struct jmploc jmploc;
7985 int checkexit = 0; 7985 int checkexit = 0;
@@ -7998,7 +7998,7 @@ evaltree(union node *n, int flags)
7998 int err = setjmp(jmploc.loc); 7998 int err = setjmp(jmploc.loc);
7999 if (err) { 7999 if (err) {
8000 /* if it was a signal, check for trap handlers */ 8000 /* if it was a signal, check for trap handlers */
8001 if (exception == EXSIG) 8001 if (exception_type == EXSIG)
8002 goto out; 8002 goto out;
8003 /* continue on the way out */ 8003 /* continue on the way out */
8004 exception_handler = savehandler; 8004 exception_handler = savehandler;
@@ -9014,7 +9014,7 @@ evalcommand(union node *cmd, int flags)
9014 9014
9015 if (evalbltin(cmdentry.u.cmd, argc, argv)) { 9015 if (evalbltin(cmdentry.u.cmd, argc, argv)) {
9016 int exit_status; 9016 int exit_status;
9017 int i = exception; 9017 int i = exception_type;
9018 if (i == EXEXIT) 9018 if (i == EXEXIT)
9019 goto raise; 9019 goto raise;
9020 exit_status = 2; 9020 exit_status = 2;
@@ -13529,7 +13529,7 @@ exitshell(void)
13529 status = exitstatus; 13529 status = exitstatus;
13530 TRACE(("pid %d, exitshell(%d)\n", getpid(), status)); 13530 TRACE(("pid %d, exitshell(%d)\n", getpid(), status));
13531 if (setjmp(loc.loc)) { 13531 if (setjmp(loc.loc)) {
13532 if (exception == EXEXIT) 13532 if (exception_type == EXEXIT)
13533/* dash bug: it just does _exit(exitstatus) here 13533/* dash bug: it just does _exit(exitstatus) here
13534 * but we have to do setjobctl(0) first! 13534 * but we have to do setjobctl(0) first!
13535 * (bug is still not fixed in dash-0.5.3 - if you run dash 13535 * (bug is still not fixed in dash-0.5.3 - if you run dash
@@ -13723,21 +13723,20 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
13723#endif 13723#endif
13724 state = 0; 13724 state = 0;
13725 if (setjmp(jmploc.loc)) { 13725 if (setjmp(jmploc.loc)) {
13726 int e; 13726 smallint e;
13727 smallint s; 13727 smallint s;
13728 13728
13729 reset(); 13729 reset();
13730 13730
13731 e = exception; 13731 e = exception_type;
13732 if (e == EXERROR) 13732 if (e == EXERROR)
13733 exitstatus = 2; 13733 exitstatus = 2;
13734 s = state; 13734 s = state;
13735 if (e == EXEXIT || s == 0 || iflag == 0 || shlvl) 13735 if (e == EXEXIT || s == 0 || iflag == 0 || shlvl)
13736 exitshell(); 13736 exitshell();
13737 13737 if (e == EXINT)
13738 if (e == EXINT) {
13739 outcslow('\n', stderr); 13738 outcslow('\n', stderr);
13740 } 13739
13741 popstackmark(&smark); 13740 popstackmark(&smark);
13742 FORCE_INT_ON; /* enable interrupts */ 13741 FORCE_INT_ON; /* enable interrupts */
13743 if (s == 1) 13742 if (s == 1)