Project

General

Profile

Actions

Bug #10866

closed

A signal handler in signal.c can corrupt the value of errno.

Added by sstewartgallus (Steven Stewart-Gallus) about 9 years ago. Updated about 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:68172]

Description

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

Updated by normalperson (Eric Wong) about 9 years ago

Good catch! I'll commit in a little bit in case we missed something,
but I think that's the only signal handler.

Actions #2

Updated by Anonymous about 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r49746.


signal.c: preserve errno

Actions

Also available in: Atom PDF

Like0
Like0Like0