Next: , Previous: Jumping, Up: Altering   [Contents][Index]


17.3 Giving your Program a Signal

signal signal

Resume execution where your program is stopped, but immediately give it the signal signal. The signal can be the name or the number of a signal. For example, on many systems signal 2 and signal SIGINT are both ways of sending an interrupt signal.

Alternatively, if signal is zero, continue execution without giving a signal. This is useful when your program stopped on account of a signal and would ordinarily see the signal when resumed with the continue command; ‘signal 0’ causes it to resume without a signal.

Note: When resuming a multi-threaded program, signal is delivered to the currently selected thread, not the thread that last reported a stop. This includes the situation where a thread was stopped due to a signal. So if you want to continue execution suppressing the signal that stopped a thread, you should select that same thread before issuing the ‘signal 0’ command. If you issue the ‘signal 0’ command with another thread as the selected one, GDB detects that and asks for confirmation.

Invoking the signal command is not the same as invoking the kill utility from the shell. Sending a signal with kill causes GDB to decide what to do with the signal depending on the signal handling tables (see Signals). The signal command passes the signal directly to your program.

signal does not repeat when you press RET a second time after executing the command.

queue-signal signal

Queue signal to be delivered immediately to the current thread when execution of the thread resumes. The signal can be the name or the number of a signal. For example, on many systems signal 2 and signal SIGINT are both ways of sending an interrupt signal. The handling of the signal must be set to pass the signal to the program, otherwise GDB will report an error. You can control the handling of signals from GDB with the handle command (see Signals).

Alternatively, if signal is zero, any currently queued signal for the current thread is discarded and when execution resumes no signal will be delivered. This is useful when your program stopped on account of a signal and would ordinarily see the signal when resumed with the continue command.

This command differs from the signal command in that the signal is just queued, execution is not resumed. And queue-signal cannot be used to pass a signal whose handling state has been set to nopass (see Signals).

See stepping into signal handlers, for information on how stepping commands behave when the thread has a signal queued.


Next: , Previous: Jumping, Up: Altering   [Contents][Index]