Interrupt (pause) running Python program in pdb?

eugene picture eugene · Apr 20, 2012 · Viewed 11.4k times · Source

In gdb, you can interrupt(pause) the program by C-c and resume.

Can you do this in pdb?

Answer

JDiMatteo picture JDiMatteo · Sep 13, 2016

No, python2's pdb doesn't support this, but you add this code to your program as a workaround:

def debug_signal_handler(signal, frame):
    import pdb
    pdb.set_trace()
import signal
signal.signal(signal.SIGINT, debug_signal_handler)

Related questions: