]> granicus.if.org Git - python/commitdiff
faulthandler: fix the handler of user signals
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 9 Aug 2012 00:43:41 +0000 (02:43 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 9 Aug 2012 00:43:41 +0000 (02:43 +0200)
Restore the errno before calling the previous signal handler, and not after.

Modules/faulthandler.c

index 469e49026836422012d89b68bc8f055c3a5889c8..4aa91242638f93cd440c66d117c25dacd0d40e83 100644 (file)
@@ -659,17 +659,22 @@ faulthandler_user(int signum)
 #ifdef HAVE_SIGACTION
     if (user->chain) {
         (void)sigaction(signum, &user->previous, NULL);
+        errno = save_errno;
+
         /* call the previous signal handler */
         raise(signum);
+
+        save_errno = errno;
         (void)faulthandler_register(signum, user->chain, NULL);
+        errno = save_errno;
     }
 #else
     if (user->chain) {
+        errno = save_errno;
         /* call the previous signal handler */
         user->previous(signum);
     }
 #endif
-    errno = save_errno;
 }
 
 static int