@@ -270,14 +270,16 @@ faulthandler_fatal_error(
270270 else
271271 _Py_DumpTraceback (fd , tstate );
272272
273- #ifndef MS_WINDOWS
274- /* call the previous signal handler: it is called if we use sigaction()
275- thanks to SA_NODEFER flag, otherwise it is deferred */
276- raise (signum );
277- #else
278- /* on Windows, don't call explictly the previous handler, because Windows
279- signal handler would not be called */
273+ #ifdef MS_WINDOWS
274+ if (signum == SIGSEGV ) {
275+ /* don't call explictly the previous handler for SIGSEGV in this signal
276+ handler, because the Windows signal handler would not be called */
277+ return ;
278+ }
280279#endif
280+ /* call the previous signal handler: it is called immediatly if we use
281+ sigaction() thanks to SA_NODEFER flag, otherwise it is deferred */
282+ raise (signum );
281283}
282284
283285/* Install handler for fatal signals (SIGSEGV, SIGFPE, ...). */
@@ -681,8 +683,9 @@ static PyObject *
681683faulthandler_sigsegv (PyObject * self , PyObject * args )
682684{
683685#if defined(MS_WINDOWS )
684- /* faulthandler_fatal_error() restores the previous signal handler and then
685- gives back the execution flow to the program. In a normal case, the
686+ /* For SIGSEGV, faulthandler_fatal_error() restores the previous signal
687+ handler and then gives back the execution flow to the program (without
688+ calling explicitly the previous error handler). In a normal case, the
686689 SIGSEGV was raised by the kernel because of a fault, and so if the
687690 program retries to execute the same instruction, the fault will be
688691 raised again.
@@ -724,13 +727,7 @@ faulthandler_sigbus(PyObject *self, PyObject *args)
724727static PyObject *
725728faulthandler_sigill (PyObject * self , PyObject * args )
726729{
727- #if defined(MS_WINDOWS )
728- /* see faulthandler_sigsegv() for the explanation about while(1) */
729- while (1 )
730- raise (SIGILL );
731- #else
732730 raise (SIGILL );
733- #endif
734731 Py_RETURN_NONE ;
735732}
736733#endif
0 commit comments