]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Hurd: Fix signal-catching functions.
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 10 May 2012 19:59:00 +0000 (12:59 -0700)
committerRoland McGrath <roland@hack.frob.com>
Thu, 10 May 2012 22:57:23 +0000 (15:57 -0700)
ChangeLog
hurd/catch-signal.c

index ff4344517054af047730221274efebad756c279e..0d93e03af9d2d1a3ac7edfb90912e31d021e0b2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-10  Samuel Thibault  <samuel.thibault@ens-lyon.org>
+
+        * hurd/catch-signal.c (hurd_catch_signal): Use sigsetjmp/siglongjmp
+        instead of setjmp/longjmp to restore the signal mask.  Call sigsetjmp
+        when handler == SIG_ERR, not when handler != SIG_ERR.
+
 2012-05-10  Thomas Schwinge  <thomas@schwinge.name>
 
        * sysdeps/mach/hurd/bits/socket.h: New file, copy from the bsd4.4 one.
index 50cd36600d74f65e033caa5e6750fe4b27786671..3f946e1033baf26c646316053097f3b9795fdec2 100644 (file)
@@ -1,5 +1,5 @@
 /* Convenience function to catch expected signals during an operation.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -27,9 +27,12 @@ hurd_catch_signal (sigset_t sigset,
                   error_t (*operate) (struct hurd_signal_preemptor *),
                   sighandler_t handler)
 {
-  jmp_buf buf;
+  /* We need to restore the signal mask, because otherwise the
+     signal-handling code will have blocked the caught signal and for
+     instance calling hurd_catch_signal again would then dump core.  */
+  sigjmp_buf buf;
   void throw (int signo, long int sigcode, struct sigcontext *scp)
-    { longjmp (buf, scp->sc_error ?: EGRATUITOUS); }
+    { siglongjmp (buf, scp->sc_error ?: EGRATUITOUS); }
 
   struct hurd_signal_preemptor preemptor =
     {
@@ -40,12 +43,12 @@ hurd_catch_signal (sigset_t sigset,
   struct hurd_sigstate *const ss = _hurd_self_sigstate ();
   error_t error;
 
-  if (handler == SIG_ERR)
+  if (handler != SIG_ERR)
     /* Not our handler; don't bother saving state.  */
     error = 0;
   else
     /* This returns again with nonzero value when we preempt a signal.  */
-    error = setjmp (buf);
+    error = sigsetjmp (buf, 1);
 
   if (error == 0)
     {