faulthandler: save/restore errno in the two signal handlers

This commit is contained in:
Victor Stinner 2011-05-07 12:20:11 +02:00
parent 97c3eb4ed5
commit c925617b54
1 changed files with 4 additions and 0 deletions

View File

@ -238,6 +238,7 @@ faulthandler_fatal_error(int signum)
unsigned int i; unsigned int i;
fault_handler_t *handler = NULL; fault_handler_t *handler = NULL;
PyThreadState *tstate; PyThreadState *tstate;
int save_errno = errno;
if (!fatal_error.enabled) if (!fatal_error.enabled)
return; return;
@ -285,6 +286,7 @@ faulthandler_fatal_error(int signum)
_Py_DumpTraceback(fd, tstate); _Py_DumpTraceback(fd, tstate);
} }
errno = save_errno;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (signum == SIGSEGV) { if (signum == SIGSEGV) {
/* don't call explictly the previous handler for SIGSEGV in this signal /* don't call explictly the previous handler for SIGSEGV in this signal
@ -593,6 +595,7 @@ faulthandler_user(int signum)
{ {
user_signal_t *user; user_signal_t *user;
PyThreadState *tstate; PyThreadState *tstate;
int save_errno = errno;
user = &user_signals[signum]; user = &user_signals[signum];
if (!user->enabled) if (!user->enabled)
@ -614,6 +617,7 @@ faulthandler_user(int signum)
return; return;
_Py_DumpTraceback(user->fd, tstate); _Py_DumpTraceback(user->fd, tstate);
} }
errno = save_errno;
} }
static int static int