From: Nobuyoshi Nakada Date: 2008-03-07T12:13:32+09:00 Subject: Re: defect for the signal usage of SIGINT in Ruby 1.9 implementation Hi, At Thu, 6 Mar 2008 18:52:14 +0900, Chirag Mistry wrote in [ruby-core:15809]: > per our understanding, it may create problem when ruby interpreter is > embedded in a process for a limited period of time. It should not install > signal handler SIG_IGN for SIGINT signal. It would be true, when embedded, but might not be true otherwise. Index: signal.c =================================================================== --- signal.c (revision 15720) +++ signal.c (working copy) @@ -1004,8 +1004,25 @@ ruby_sig_finalize() sighandler_t oldfunc; - oldfunc = ruby_signal(SIGINT, SIG_IGN); +#ifdef POSIX_SIGNAL + struct sigaction oldact; + MEMZERO(&oldact, struct sigaction, 1); + sigaction(SIGINT, NULL, &oldact); +#ifdef SA_SIGINFO + if (oldact.sa_flags & SA_SIGINFO) + oldfunc = (sighandler_t)oldact.sa_sigaction; + else +#else + oldfunc = oldact.sa_handler; +#endif if (oldfunc == sighandler) { ruby_signal(SIGINT, SIG_DFL); } +#else + oldfunc = ruby_signal(SIGINT, SIG_IGN); + if (oldfunc == sighandler) { + oldfunc = SIG_DFL; + } + ruby_signal(SIGINT, oldfunc); +#endif } -- Nobu Nakada