[Python-Dev] Trap SIGSEGV and SIGFPE

James Y Knight foom at fuhm.net
Thu Dec 11 17:40:28 CET 2008

On Dec 11, 2008, at 11:08 AM, Jeffrey Yasskin wrote:

> On Thu, Dec 11, 2008 at 1:34 AM, Victor Stinner
> <victor.stinner at haypocalc.com> wrote:
>> But if -as many people wrote-
>> Python is totally broken after a segfault, it is maybe not a good  
>> idea :-)
> While it's true that after a segfault or unexpected longjmp, there are
> no guarantees whatsoever about the state of the python program, the
> program will often just happen to work, and there are at least some
> programs I've worked on that would rather take the risk in order to
> try to shut down gracefully.

I ran an interactive game for years (written in C, mind you, not  
python), where the SIGSEGV handler simply recursively reinvoked the  
main loop, after disabling the command that caused a SEGV if it had  
caused a SEGV twice already. It almost always worked and continued  
running without issue. YMMV, of course. :)


More information about the Python-Dev mailing list