title: Handling signals with gdb
body: <p>I'm debugging a C++ app for Ubuntu 10.04 that sometimes receives a <code>SIGKILL</code> signal.
  I want to <em>catch</em> the signal and stop it from killing the execution, just to see if I can get some useful info of the app's state at that precise moment.</p>
  
  <p>Reading the <a href="http://www.ofb.net/gnu/gdb/gdb_38.html#SEC38" rel="noreferrer">gdb documentation</a> I found the <code>handle</code> command, so I tried to apply it to the SIGKILL signal:</p>
  
  <pre><code>(gdb) handle SIGKILL stop nopass
  Signal        Stop  Print   Pass to program Description
  SIGKILL       Yes   Yes     No              Killed
  </code></pre>
  
  <p>So, as I understand this correctly:</p>
  
  <pre><code>stop
      GDB should stop your program when this signal happens. This implies the print keyword as well. 
  print
      GDB should print a message when this signal happens. 
  nopass
      GDB should not allow your program to see this signal. 
  </code></pre>
  
  <p>once the <code>SIGKILL</code> signal is emitted, <code>gdb</code> should somehow catch it, print the message, stop the execution and don't let the app kill itself, right?</p>
  
  <p>The problem is that this doesn't happen and the app terminates.</p>
  
  <p>Do you know how could I <em>catch</em> the signal?</p>
  
  <p><strong>Useful Info:</strong></p>
  
  <ul>
  <li>The piece of code that is running when the signal is emitted is executed <strong>in another thread.</strong></li>
  <li><strong>gdb version:</strong> 4.4.3</li>
  <li><strong>g++ version:</strong> 7.1</li>
  </ul>