1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: Signaling</title> 18 19<meta name="description" content="Debugging with GDB: Signaling"> 20<meta name="keywords" content="Debugging with GDB: Signaling"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="Altering.html#Altering" rel="up" title="Altering"> 29<link href="Returning.html#Returning" rel="next" title="Returning"> 30<link href="Jumping.html#Jumping" rel="previous" title="Jumping"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="Signaling"></a> 65<div class="header"> 66<p> 67Next: <a href="Returning.html#Returning" accesskey="n" rel="next">Returning</a>, Previous: <a href="Jumping.html#Jumping" accesskey="p" rel="previous">Jumping</a>, Up: <a href="Altering.html#Altering" accesskey="u" rel="up">Altering</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 68</div> 69<hr> 70<a name="Giving-Your-Program-a-Signal"></a> 71<h3 class="section">17.3 Giving Your Program a Signal</h3> 72<a name="index-deliver-a-signal-to-a-program"></a> 73 74<dl compact="compact"> 75<dd><a name="index-signal"></a> 76</dd> 77<dt><code>signal <var>signal</var></code></dt> 78<dd><p>Resume execution where your program is stopped, but immediately give it the 79signal <var>signal</var>. The <var>signal</var> can be the name or the number of a 80signal. For example, on many systems <code>signal 2</code> and <code>signal 81SIGINT</code> are both ways of sending an interrupt signal. 82</p> 83<p>Alternatively, if <var>signal</var> is zero, continue execution without 84giving a signal. This is useful when your program stopped on account of 85a signal and would ordinarily see the signal when resumed with the 86<code>continue</code> command; ‘<samp>signal 0</samp>’ causes it to resume without a 87signal. 88</p> 89<p><em>Note:</em> When resuming a multi-threaded program, <var>signal</var> is 90delivered to the currently selected thread, not the thread that last 91reported a stop. This includes the situation where a thread was 92stopped due to a signal. So if you want to continue execution 93suppressing the signal that stopped a thread, you should select that 94same thread before issuing the ‘<samp>signal 0</samp>’ command. If you issue 95the ‘<samp>signal 0</samp>’ command with another thread as the selected one, 96<small>GDB</small> detects that and asks for confirmation. 97</p> 98<p>Invoking the <code>signal</code> command is not the same as invoking the 99<code>kill</code> utility from the shell. Sending a signal with <code>kill</code> 100causes <small>GDB</small> to decide what to do with the signal depending on 101the signal handling tables (see <a href="Signals.html#Signals">Signals</a>). The <code>signal</code> command 102passes the signal directly to your program. 103</p> 104<p><code>signal</code> does not repeat when you press <tt class="key">RET</tt> a second time 105after executing the command. 106</p> 107<a name="index-queue_002dsignal"></a> 108</dd> 109<dt><code>queue-signal <var>signal</var></code></dt> 110<dd><p>Queue <var>signal</var> to be delivered immediately to the current thread 111when execution of the thread resumes. The <var>signal</var> can be the name or 112the number of a signal. For example, on many systems <code>signal 2</code> and 113<code>signal SIGINT</code> are both ways of sending an interrupt signal. 114The handling of the signal must be set to pass the signal to the program, 115otherwise <small>GDB</small> will report an error. 116You can control the handling of signals from <small>GDB</small> with the 117<code>handle</code> command (see <a href="Signals.html#Signals">Signals</a>). 118</p> 119<p>Alternatively, if <var>signal</var> is zero, any currently queued signal 120for the current thread is discarded and when execution resumes no signal 121will be delivered. This is useful when your program stopped on account 122of a signal and would ordinarily see the signal when resumed with the 123<code>continue</code> command. 124</p> 125<p>This command differs from the <code>signal</code> command in that the signal 126is just queued, execution is not resumed. And <code>queue-signal</code> cannot 127be used to pass a signal whose handling state has been set to <code>nopass</code> 128(see <a href="Signals.html#Signals">Signals</a>). 129</p></dd> 130</dl> 131 132<p>See <a href="Signals.html#stepping-into-signal-handlers">stepping into signal handlers</a>, for information on how stepping 133commands behave when the thread has a signal queued. 134</p> 135<hr> 136<div class="header"> 137<p> 138Next: <a href="Returning.html#Returning" accesskey="n" rel="next">Returning</a>, Previous: <a href="Jumping.html#Jumping" accesskey="p" rel="previous">Jumping</a>, Up: <a href="Altering.html#Altering" accesskey="u" rel="up">Altering</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 139</div> 140 141 142 143</body> 144</html> 145