summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-30 01:57:06 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-30 01:57:06 +0000
commit18bc6c31a1a0831ae6dda645a13b2df13d761fe8 (patch)
treea0849e5d3ad49cf0d5759c42e0f152d543a4ef43 /signal.c
parent1054b79609f3f468470ae022cea5445e58ed831b (diff)
* vm.c (th_init): preallocate alternative stack.
NoMemoryError is better than rb_bug, of course. Patch by Eric Wong. [ruby-core:38572][ruby-core:38594]. * signal.c (rb_register_sigaltstack): ditto. * vm_core.h: moved ALT_STACK_SIZE definition from signal.c. * vm.c (thread_free): use xfree() instead of free(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/signal.c b/signal.c
index 3d9a1dbde5..02ec9d3ebc 100644
--- a/signal.c
+++ b/signal.c
@@ -423,29 +423,22 @@ typedef RETSIGTYPE ruby_sigaction_t(int);
#ifdef POSIX_SIGNAL
#ifdef USE_SIGALTSTACK
-#ifdef SIGSTKSZ
-#define ALT_STACK_SIZE (SIGSTKSZ*2)
-#else
-#define ALT_STACK_SIZE (4*1024)
-#endif
/* alternate stack for SIGSEGV */
void
rb_register_sigaltstack(rb_thread_t *th)
{
stack_t newSS, oldSS;
- if (th->altstack) return;
+ if (!th->altstack)
+ rb_bug("rb_register_sigaltstack: th->altstack not initialized\n");
- newSS.ss_sp = th->altstack = malloc(ALT_STACK_SIZE);
- if (newSS.ss_sp == NULL)
- /* should handle error */
- rb_bug("rb_register_sigaltstack. malloc error\n");
+ newSS.ss_sp = th->altstack;
newSS.ss_size = ALT_STACK_SIZE;
newSS.ss_flags = 0;
sigaltstack(&newSS, &oldSS); /* ignore error. */
}
-#endif
+#endif /* USE_SIGALTSTACK */
static sighandler_t
ruby_signal(int signum, sighandler_t handler)