title: GDB not interrupting program immediately
body: <p>When debugging a large C application, I see strange behavior from <code>gdb</code>: 
  I can always interrupt the program pressing <code>Ctrl+C</code>:</p>
  
  <pre><code>^C
  Program received signal SIGINT, Interrupt.
  0x76f58964 in select () at ../sysdeps/unix/syscall-template.S:81
  81      in ../sysdeps/unix/syscall-template.S
  (gdb)
  </code></pre>
  
  <p>However, after a sufficient runtime of the program (like > 1 day), I cannot easily interrupt the program anymore.
  When trying to interrupt the program with <code>Ctrl+C</code>, <code>gdb</code> just shows</p>
  
  <pre><code>^C
  Program received signal SIGINT, Interrupt.
  </code></pre>
  
  <p>and hangs there for several minutes up to hours.
  If it takes longer than a few minutes, I usually open another terminal and kill <code>gdb</code> manually to be able to continue.</p>
  
  <p><strong>Question: Is this expected behavior from <code>gdb</code>? Can I set an option to avoid this?</strong></p>
  
  <p>Further details:</p>
  
  <ul>
  <li>The application is <code>FTL</code> (<a href="https://github.com/pi-hole/FTL" rel="nofollow noreferrer">https://github.com/pi-hole/FTL</a>)</li>
  <li>It is multi-threaded using <code>pthreads</code></li>
  <li>During the waiting time after hitting <code>Ctrl+C</code>, <code>gdb</code> is at 100% CPU.</li>
  </ul>
  
  <p><strong>Edit: Further details</strong></p>
  
  <p>I ran <code>perf record -p $(pidof gdb)</code> for about 10 seconds while <code>gdb</code> was frozen. <code>perf report</code> returns:</p>
  
  <pre><code>90,82%  gdb      gdb                [.] find_thread_ptid                                                                                                   
   9,13%  gdb      gdb                [.] ptid_equal                                                                                                         
   0,02%  gdb      gdb                [.] iterate_over_threads                                                                                               
   0,01%  gdb      [kernel.kallsyms]  [k] run_timer_softirq                                                                                                  
   0,01%  gdb      gdb                [.] 0x0016a9a4                                                                                                         
   0,00%  gdb      gdb                [.] 0x0015a480                                                                                                         
   0,00%  gdb      gdb                [.] 0x0016a998                                                                                                         
   0,00%  gdb      gdb                [.] is_exited
  </code></pre>
  
  <p>After a few minutes, <code>gdb</code> finished and I ran <code>info threads</code> which still showed only three threads (as before):</p>
  
  <pre><code>(gdb) info threads
    Id   Target Id         Frame 
    3    Thread 0x764b8460 (LWP 10114) "socket listener" 0x76f60260 in accept () at ../sysdeps/unix/syscall-template.S:81
    2    Thread 0x76cb8460 (LWP 10113) "loganalyzer" 0x76f58964 in select () at ../sysdeps/unix/syscall-template.S:81
  * 1    Thread 0x76e65000 (LWP 10098) "pihole-FTL" 0x76f58964 in select () at ../sysdeps/unix/syscall-template.S:81
  </code></pre>