From: sstewartgallus00@... Date: 2015-02-18T17:46:37+00:00 Subject: [ruby-core:68172] [Ruby trunk - Bug #10866] [Open] A signal handler in signal.c can corrupt the value of errno. Issue #10866 has been reported by Steven Stewart-Gallus. ---------------------------------------- Bug #10866: A signal handler in signal.c can corrupt the value of errno. https://bugs.ruby-lang.org/issues/10866 * Author: Steven Stewart-Gallus * Status: Open * Priority: Normal * Assignee: * ruby -v: 2.2.0 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- A signal handler in signal.c can corrupt the value of errno. This is common mistake. It should save and restore errno as in the following patch. I think this is the only signal handler used but I am not that familiar with the code. Index: signal.c =================================================================== --- signal.c (revision 49641) +++ signal.c (working copy) @@ -688,11 +688,15 @@ static RETSIGTYPE sighandler(int sig) { + int old_errnum = errno; + signal_enque(sig); rb_thread_wakeup_timer_thread(); #if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL) ruby_signal(sig, sighandler); #endif + + errno = old_errnum; } int -- https://bugs.ruby-lang.org/