Partly as a result of the Matthew Fleming's Google 2006 Summer of Code
project, pydb
contains signal handling similar to gdb
.
A signal is an asynchronous event that can happen in a program. Note: only the main thread can intercept a signal, so if the main thread is blocked, handling of the signal will be delayed.
The operating system defines the possible kinds of signals, and gives
each kind a name and a number. For example, in Unix SIGINT
is
the signal a program gets when you type an interrupt character (often
C-c
); SIGALRM
occurs when the alarm clock timer goes off
(which happens only if your program has requested an alarm).
When pydb
changes signal handlers, it saves any value that the
debugged script might have installed.
The debugger also installs an interrupt handler SIGINT
so that
errant programs can be interrupted and you can find out where the
program was when you interrupted it.
Some signals, including SIGALRM
, are a normal part of the
functioning of your program. Others, such as SIGSEGV
, indicate
errors; these signals are fatal-they kill your program immediately if the
program has not specified in advance some other way to handle the signal.
SIGINT
does not indicate an error in your program, but it is normally
fatal so it can carry out the purpose of the interrupt: to kill the program.
pydb
has the ability to detect any occurrence of a signal in
your program. You tell pydb
in advance what to do for each
kind of signal. In the course of running the program, signal handlers
may be changed, and the debugger has the ability to watch for this
possibility and act accordingly. However since this adds a bit of
overhead it is turned off by default. set sigcheck
and
show sigcheck
can be used to set/show whether this checking is
done.
Normally, pydb
is set up to let the non-erroneous signals like
SIGALRM
be silently passed to your program (so as not to
interfere with their role in the program's functioning) but to stop
your program immediately whenever an error signal happens. You can
change these settings with the handle
command.