diff -prU2 Parser/intrcheck.c Parser/intrcheck.c --- Parser/intrcheck.c +++ Parser/intrcheck.c @@ -98,9 +98,11 @@ PyOS_InterruptOccurred(void) /* Default version -- for real operating systems and for Standard C */ +#include #include #include #include +#include -static int interrupted; +static volatile sig_atomic_t interrupted; void @@ -122,4 +124,5 @@ intcatcher(int sig) { extern void Py_Exit(int); + int save_errno = errno; static char message[] = "python: to interrupt a truly hanging Python program, interrupt once more.\n"; @@ -131,10 +134,13 @@ intcatcher(int sig) break; case 2: - interrupted = 0; Py_Exit(1); break; + case 3: + interrupted = 0; + _exit(1); /* or POSIX _Exit(1) */ } PyOS_setsig(SIGINT, intcatcher); Py_AddPendingCall(checksignals_witharg, NULL); + if (errno != save_errno) errno = save_errno; }