diff --git a/ChangeLog b/ChangeLog index f780c1190f..3a732b4cb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 30 23:48:07 2007 Yukihiro Matsumoto + + * signal.c (ruby_signal): use SA_SIGINFO if available. + [ ruby-Patches-6418 ] + Fri Nov 30 22:52:54 2007 Yukihiro Matsumoto * signal.c (trap_signm): SIGVTALRM no longer used for green diff --git a/include/ruby/intern.h b/include/ruby/intern.h index b8c43b2717..a43d4d31ab 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -472,7 +472,7 @@ VALUE rb_f_kill(int, VALUE*); void rb_gc_mark_trap_list(void); #ifdef POSIX_SIGNAL #define posix_signal ruby_posix_signal -void posix_signal(int, RETSIGTYPE (*)(int)); +RETSIGTYPE (*posix_signal(int, RETSIGTYPE (*)(int)))(int); #endif void ruby_sig_finalize(void); void rb_trap_exit(void); diff --git a/process.c b/process.c index 13f4bef765..525a546d6e 100644 --- a/process.c +++ b/process.c @@ -1668,6 +1668,10 @@ rb_f_abort(int argc, VALUE *argv) #if defined(sun) #define signal(a,b) sigset(a,b) +#else +# if defined(POSIX_SIGNAL) +# define signal(a,b) posix_signal(a,b) +# endif #endif void diff --git a/signal.c b/signal.c index 6eba832e5d..5723d7f031 100644 --- a/signal.c +++ b/signal.c @@ -414,9 +414,15 @@ ruby_signal(int signum, sighandler_t handler) rb_trap_accept_nativethreads[signum] = 0; - sigact.sa_handler = handler; sigemptyset(&sigact.sa_mask); +#ifdef SA_SIGINFO + sigact.sa_sigaction = (void (*)(int, siginfo_t*, void*))handler; + sigact.sa_flags = SA_SIGINFO; +#else + sigact.sa_handler = handler; sigact.sa_flags = 0; +#endif + #ifdef SA_NOCLDWAIT if (signum == SIGCHLD && handler == SIG_IGN) sigact.sa_flags |= SA_NOCLDWAIT; @@ -425,7 +431,7 @@ ruby_signal(int signum, sighandler_t handler) return old.sa_handler; } -void +sighandler_t posix_signal(int signum, sighandler_t handler) { ruby_signal(signum, handler);