diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-27 07:32:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-27 07:32:56 +0000 |
commit | ab9fd5dbf79cd6316fd49e42fa57dbb77500f539 (patch) | |
tree | da2b09e4069b1648e43869de93206df15be6b217 | |
parent | 550f10ca5be5018f78df5c4a7e42430ab96f7b9d (diff) | |
download | ruby-ab9fd5dbf79cd6316fd49e42fa57dbb77500f539.tar.gz |
* signal.c (register_sigaltstack): stores alt stack for debug
purpose.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | signal.c | 24 |
2 files changed, 19 insertions, 14 deletions
@@ -1,3 +1,12 @@ +Thu Nov 27 16:32:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * signal.c (register_sigaltstack): stores alt stack for debug + purpose. + +Thu Nov 27 16:12:33 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * signal.c (ruby_sigaction_t): added. + Thu Nov 27 15:59:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * gc.c (ruby_stack_check): no check if using sigaltstack. @@ -429,25 +429,25 @@ typedef RETSIGTYPE ruby_sigaction_t(int); #endif /* alternate stack for SIGSEGV */ static void -register_sigaltstack() +register_sigaltstack(void) { - static int is_altstack_defined = 0; + static void *altstack = 0; stack_t newSS, oldSS; - if (is_altstack_defined) - return; + if (altstack) return; - newSS.ss_sp = malloc(ALT_STACK_SIZE); + newSS.ss_sp = altstack = malloc(ALT_STACK_SIZE); if (newSS.ss_sp == NULL) - /* should handle error */ - rb_bug("register_sigaltstack. malloc error\n"); + /* should handle error */ + rb_bug("register_sigaltstack. malloc error\n"); newSS.ss_size = ALT_STACK_SIZE; newSS.ss_flags = 0; if (sigaltstack(&newSS, &oldSS) < 0) - rb_bug("register_sigaltstack. error\n"); - is_altstack_defined = 1; + rb_bug("register_sigaltstack. error\n"); } +#else +#define register_sigaltstack() ((void)0) #endif static sighandler_t @@ -474,7 +474,7 @@ ruby_signal(int signum, sighandler_t handler) #endif #if defined(SA_ONSTACK) && defined(USE_SIGALTSTACK) if (signum == SIGSEGV) - sigact.sa_flags |= SA_ONSTACK; + sigact.sa_flags |= SA_ONSTACK; #endif if (sigaction(signum, &sigact, &old) < 0) rb_bug("sigaction error.\n"); @@ -716,9 +716,7 @@ default_handler(int sig) #ifdef SIGSEGV case SIGSEGV: func = (sighandler_t)sigsegv; -#ifdef USE_SIGALTSTACK register_sigaltstack(); -#endif break; #endif #ifdef SIGPIPE @@ -1126,9 +1124,7 @@ Init_signal(void) install_sighandler(SIGBUS, sigbus); #endif #ifdef SIGSEGV -#ifdef USE_SIGALTSTACK register_sigaltstack(); -#endif install_sighandler(SIGSEGV, (sighandler_t)sigsegv); #endif } |