summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-13 16:20:26 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-13 16:20:26 +0000
commit50587316b8c66f2d18756de6bb041bd38af8d17b (patch)
tree2d56fb93ced6de44c523632bf0341061c66ccf81 /signal.c
parenta22df39467709c4f270f45fbdfb0b548156bd633 (diff)
* vm_core.c (rb_thread_struct): add a field for sigaltstack.
* thread_pthread.c (thread_start_func_1): initialize machine stack information. * thread.c (thread_start_func_2): set sigaltstack for each sub thread. [ruby-core:24540] [ruby-core:30207] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/signal.c b/signal.c
index 3c563cf120..9ecf4fc0f2 100644
--- a/signal.c
+++ b/signal.c
@@ -420,10 +420,6 @@ static struct {
#define sighandler_t sh_t
#endif
-#if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
-#define USE_SIGALTSTACK
-#endif
-
typedef RETSIGTYPE (*sighandler_t)(int);
#ifdef USE_SIGALTSTACK
typedef void ruby_sigaction_t(int, siginfo_t*, void*);
@@ -442,18 +438,17 @@ typedef RETSIGTYPE ruby_sigaction_t(int);
#define ALT_STACK_SIZE (4*1024)
#endif
/* alternate stack for SIGSEGV */
-static void
-register_sigaltstack(void)
+void
+rb_register_sigaltstack(rb_thread_t *th)
{
- static void *altstack = 0;
stack_t newSS, oldSS;
- if (altstack) return;
+ if (th->altstack) return;
- newSS.ss_sp = altstack = malloc(ALT_STACK_SIZE);
+ newSS.ss_sp = th->altstack = malloc(ALT_STACK_SIZE);
if (newSS.ss_sp == NULL)
/* should handle error */
- rb_bug("register_sigaltstack. malloc error\n");
+ rb_bug("rb_register_sigaltstack. malloc error\n");
newSS.ss_size = ALT_STACK_SIZE;
newSS.ss_flags = 0;
@@ -737,7 +732,7 @@ default_handler(int sig)
case SIGSEGV:
func = (sighandler_t)sigsegv;
# ifdef USE_SIGALTSTACK
- register_sigaltstack();
+ rb_register_sigaltstack(GET_THREAD());
# endif
break;
#endif
@@ -1130,7 +1125,7 @@ Init_signal(void)
#endif
#ifdef SIGSEGV
# ifdef USE_SIGALTSTACK
- register_sigaltstack();
+ rb_register_sigaltstack(GET_THREAD());
# endif
install_sighandler(SIGSEGV, (sighandler_t)sigsegv);
#endif