@@ -94,6 +94,7 @@ static SigHandler *old_winch = (SigHandler *)SIG_DFL;
94
94
#endif
95
95
96
96
static void initialize_shell_signals PARAMS ((void ));
97
+ static void kill_shell PARAMS ((int ));
97
98
98
99
void
99
100
initialize_signals (reinit )
@@ -486,6 +487,8 @@ restore_sigmask ()
486
487
#endif
487
488
}
488
489
490
+ static int handling_termsig = 0 ;
491
+
489
492
sighandler
490
493
termsig_sighandler (sig )
491
494
int sig ;
@@ -532,6 +535,14 @@ termsig_sighandler (sig)
532
535
sig == terminating_signal )
533
536
terminate_immediately = 1 ;
534
537
538
+ /* If we are currently handling a terminating signal, we have a couple of
539
+ choices here. We can ignore this second terminating signal and let the
540
+ shell exit from the first one, or we can exit immediately by killing
541
+ the shell with this signal. This code implements the latter; to implement
542
+ the former, replace the kill_shell(sig) with return. */
543
+ if (handling_termsig )
544
+ kill_shell (sig ); /* just short-circuit now */
545
+
535
546
terminating_signal = sig ;
536
547
537
548
if (terminate_immediately )
@@ -564,16 +575,13 @@ void
564
575
termsig_handler (sig )
565
576
int sig ;
566
577
{
567
- static int handling_termsig = 0 ;
568
- int i , core ;
569
- sigset_t mask ;
570
-
571
578
/* Simple semaphore to keep this function from being executed multiple
572
579
times. Since we no longer are running as a signal handler, we don't
573
580
block multiple occurrences of the terminating signals while running. */
574
581
if (handling_termsig )
575
582
return ;
576
- handling_termsig = 1 ;
583
+
584
+ handling_termsig = terminating_signal ; /* for termsig_sighandler */
577
585
terminating_signal = 0 ; /* keep macro from re-testing true. */
578
586
579
587
/* I don't believe this condition ever tests true. */
@@ -613,6 +621,16 @@ termsig_handler (sig)
613
621
614
622
run_exit_trap (); /* XXX - run exit trap possibly in signal context? */
615
623
624
+ kill_shell (sig );
625
+ }
626
+
627
+ static void
628
+ kill_shell (sig )
629
+ int sig ;
630
+ {
631
+ int i , core ;
632
+ sigset_t mask ;
633
+
616
634
/* We don't change the set of blocked signals. If a user starts the shell
617
635
with a terminating signal blocked, we won't get here (and if by some
618
636
magic chance we do, we'll exit below). What we do is to restore the
0 commit comments