From cb33f92ef2384de47b3693f88659840b3053ba90 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Wed, 24 Apr 2002 21:25:46 +0000 Subject: [PATCH] Get rid of incomprehensible special-case treatment of SIGABRT. Might have made sense once but it doesn't any more. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@141 --- coregrind/vg_kerneliface.h | 2 -- coregrind/vg_signals.c | 28 ++++++---------------------- vg_kerneliface.h | 2 -- vg_signals.c | 28 ++++++---------------------- 4 files changed, 12 insertions(+), 48 deletions(-) diff --git a/coregrind/vg_kerneliface.h b/coregrind/vg_kerneliface.h index 932f6c7d87..062f1e43d2 100644 --- a/coregrind/vg_kerneliface.h +++ b/coregrind/vg_kerneliface.h @@ -111,13 +111,11 @@ typedef #define VKI_SA_RESTORER 0x04000000 #endif -#define VKI_SIGABRT 6 #define VKI_SIGSEGV 11 #define VKI_SIGBUS 7 #define VKI_SIGILL 4 #define VKI_SIGFPE 8 #define VKI_SIGKILL 9 -#define VKI_SIGABRT 6 #define VKI_SIGSTOP 19 #define VKI_SIGTERM 15 diff --git a/coregrind/vg_signals.c b/coregrind/vg_signals.c index d0359767e5..7fc3b0ba1a 100644 --- a/coregrind/vg_signals.c +++ b/coregrind/vg_signals.c @@ -393,19 +393,6 @@ static void VG_(oursignalhandler) ( Int sigNo ) vg_assert((Char*)(&(VG_(sigstack)[0])) <= (Char*)(&dummy_local)); vg_assert((Char*)(&dummy_local) < (Char*)(&(VG_(sigstack)[10000]))); - if (sigNo == VKI_SIGABRT && VG_(sighandler)[sigNo] == NULL) { - /* We get here if SIGABRT is delivered and the client hasn't - asked to catch it. The aim is to exit in a controlled - manner. */ - if (VG_(clo_trace_signals)) { - VG_(add_to_msg)("catching SIGABRT"); - VG_(end_msg)(); - } - VG_(ksignal)(VKI_SIGABRT, VKI_SIG_DFL); - VG_(longjmpd_on_signal) = VKI_SIGABRT; - __builtin_longjmp(VG_(scheduler_jmpbuf),1); - } - VG_(block_all_host_signals)( &saved_procmask ); if (VG_(sighandler)[sigNo] == NULL) { @@ -555,8 +542,6 @@ void VG_(sigstartup_actions) ( void ) } } - VG_(ksignal)(VKI_SIGABRT, &VG_(oursignalhandler)); - /* Finally, restore the blocking mask. */ VG_(restore_host_signals)( &saved_procmask ); } @@ -634,7 +619,7 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) if ( (param1 == VKI_SIGKILL || param1 == VKI_SIGSTOP) && new_action && new_action->ksa_handler != VKI_SIG_DFL) - goto bad_sigkill; + goto bad_sigkill_or_sigstop; our_old_handler = VG_(sighandler)[param1]; /* VG_(printf)("old handler = 0x%x\n", our_old_handler); */ @@ -673,7 +658,7 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) vg_assert(our_old_handler == NULL); } else { /* There's a handler. */ - if (param1 != VKI_SIGKILL && param1 != VKI_SIGABRT) { + if (param1 != VKI_SIGKILL && param1 != VKI_SIGSTOP) { vg_assert(old_action->ksa_handler == &VG_(oursignalhandler)); vg_assert((old_action->ksa_flags & VKI_SA_ONSTACK) != 0); } @@ -689,8 +674,6 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) old_action->ksa_flags &= ~VKI_SA_RESTART; } } - - VG_(ksignal)(VKI_SIGABRT, &VG_(oursignalhandler)); goto good; good: @@ -704,10 +687,11 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) VG_(baseBlock)[VGOFF_(m_eax)] = (UInt)(-VKI_EINVAL); return; - bad_sigkill: + bad_sigkill_or_sigstop: VG_(message)(Vg_UserMsg, - "Warning: attempt to set SIGKILL handler in __NR_sigaction.", - param1); + "Warning: attempt to set %s handler in __NR_sigaction.", + param1 == VKI_SIGKILL ? "SIGKILL" : "SIGSTOP" ); + VG_(baseBlock)[VGOFF_(m_eax)] = (UInt)(-VKI_EINVAL); return; } diff --git a/vg_kerneliface.h b/vg_kerneliface.h index 932f6c7d87..062f1e43d2 100644 --- a/vg_kerneliface.h +++ b/vg_kerneliface.h @@ -111,13 +111,11 @@ typedef #define VKI_SA_RESTORER 0x04000000 #endif -#define VKI_SIGABRT 6 #define VKI_SIGSEGV 11 #define VKI_SIGBUS 7 #define VKI_SIGILL 4 #define VKI_SIGFPE 8 #define VKI_SIGKILL 9 -#define VKI_SIGABRT 6 #define VKI_SIGSTOP 19 #define VKI_SIGTERM 15 diff --git a/vg_signals.c b/vg_signals.c index d0359767e5..7fc3b0ba1a 100644 --- a/vg_signals.c +++ b/vg_signals.c @@ -393,19 +393,6 @@ static void VG_(oursignalhandler) ( Int sigNo ) vg_assert((Char*)(&(VG_(sigstack)[0])) <= (Char*)(&dummy_local)); vg_assert((Char*)(&dummy_local) < (Char*)(&(VG_(sigstack)[10000]))); - if (sigNo == VKI_SIGABRT && VG_(sighandler)[sigNo] == NULL) { - /* We get here if SIGABRT is delivered and the client hasn't - asked to catch it. The aim is to exit in a controlled - manner. */ - if (VG_(clo_trace_signals)) { - VG_(add_to_msg)("catching SIGABRT"); - VG_(end_msg)(); - } - VG_(ksignal)(VKI_SIGABRT, VKI_SIG_DFL); - VG_(longjmpd_on_signal) = VKI_SIGABRT; - __builtin_longjmp(VG_(scheduler_jmpbuf),1); - } - VG_(block_all_host_signals)( &saved_procmask ); if (VG_(sighandler)[sigNo] == NULL) { @@ -555,8 +542,6 @@ void VG_(sigstartup_actions) ( void ) } } - VG_(ksignal)(VKI_SIGABRT, &VG_(oursignalhandler)); - /* Finally, restore the blocking mask. */ VG_(restore_host_signals)( &saved_procmask ); } @@ -634,7 +619,7 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) if ( (param1 == VKI_SIGKILL || param1 == VKI_SIGSTOP) && new_action && new_action->ksa_handler != VKI_SIG_DFL) - goto bad_sigkill; + goto bad_sigkill_or_sigstop; our_old_handler = VG_(sighandler)[param1]; /* VG_(printf)("old handler = 0x%x\n", our_old_handler); */ @@ -673,7 +658,7 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) vg_assert(our_old_handler == NULL); } else { /* There's a handler. */ - if (param1 != VKI_SIGKILL && param1 != VKI_SIGABRT) { + if (param1 != VKI_SIGKILL && param1 != VKI_SIGSTOP) { vg_assert(old_action->ksa_handler == &VG_(oursignalhandler)); vg_assert((old_action->ksa_flags & VKI_SA_ONSTACK) != 0); } @@ -689,8 +674,6 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) old_action->ksa_flags &= ~VKI_SA_RESTART; } } - - VG_(ksignal)(VKI_SIGABRT, &VG_(oursignalhandler)); goto good; good: @@ -704,10 +687,11 @@ void VG_(do__NR_sigaction) ( ThreadId tid ) VG_(baseBlock)[VGOFF_(m_eax)] = (UInt)(-VKI_EINVAL); return; - bad_sigkill: + bad_sigkill_or_sigstop: VG_(message)(Vg_UserMsg, - "Warning: attempt to set SIGKILL handler in __NR_sigaction.", - param1); + "Warning: attempt to set %s handler in __NR_sigaction.", + param1 == VKI_SIGKILL ? "SIGKILL" : "SIGSTOP" ); + VG_(baseBlock)[VGOFF_(m_eax)] = (UInt)(-VKI_EINVAL); return; } -- 2.47.2