title: Preventing debugging session from pausing after each inferior exits
body: <p>I'm debugging a tree of processes using <a href="https://sourceware.org/gdb/onlinedocs/gdb/Inferiors-and-Programs.html" rel="noreferrer"><code>gdb</code>'s very handy multiple-inferior support</a>:</p>
  
  <pre><code>(gdb) set detach-on-fork off
  (gdb) set schedule-multiple on
  (gdb) set follow-fork-mode parent
  (gdb) break PostgresMain
  (gdb) break PostmasterMain
  </code></pre>
  
  <p>and now need to let things run until I hit one of the future breakpoints in some yet to be spawned inferior.</p>
  
  <p>However, <code>gdb</code> seems to be "helpfully" pausing whenever an inferior exits normally, or at least blocking cleanup of the inferior so that its parent's <code>wait()</code> can return:</p>
  
  <pre><code>(gdb) c
  [New process 16505]
  process 16505 is executing new program: /home/craig/pg/bdr/bin/pg_config
  Reading symbols from /home/craig/pg/bdr/bin/pg_config...done.
  [Inferior 2 (process 16505) exited normally]
  (gdb) info inferior
    Num  Description       Executable        
  * 2    &lt;null&gt;            /home/craig/pg/bdr/bin/pg_config 
    1    process 16501     /usr/bin/make     
  (gdb) inferior 1
  [Switching to inferior 1 [process 16501] (/usr/bin/make)]
  [Switching to thread 1 (process 16501)] 
  #0  0x0000003bc68bc502 in __libc_wait (stat_loc=0x7fffffffbc78) at ../sysdeps/unix/sysv/linux/wait.c:30
  30          return INLINE_SYSCALL (wait4, 4, WAIT_ANY, stat_loc, 0,
  (gdb)
  </code></pre>
  
  <p>so I have to endlessly:</p>
  
  <pre><code>(gdb) inferior 1
  (gdb) c
  </code></pre>
  
  <p>to carry on. About 70 times, before I hit the desired breakpoint in a child of a child of a child.</p>
  
  <p>I <em>think</em> what's happening is that <code>gdb</code> treats process exit as a stop event, and since <code>non-stop</code> is set to <code>off</code> (the default) it stops all threads in all inferiors when one thread stops. However, this inferior has terminated, it isn't a normal stop event, so you can't just <code>cont</code> it, you have to switch to another process first.</p>
  
  <p>Is there some way to stop gdb pausing at each inferior exit? I would've expected <code>follow-fork-mode parent</code> with <code>schedule-multiple on</code> to do the trick, but <code>gdb</code> seems to still want to stop when an inferior exits.</p>
  
  <p>I guess I'm looking for something like a "skip proc-exit", or a virtual signal I can change the handler policy on so it doesn't stop.</p>
  
  <hr>
  
  <p><code>set non-stop on</code> seems like it should be the right answer, but I suspect it's broken for multiple inferiors.</p>
  
  <p>If I use <code>non-stop on</code>, then after the first exit trap, <code>gdb</code>'s internal state indicates that inferior 1 is running:</p>
  
  <pre><code>(gdb) info inferior
    Num  Description       Executable        
  * 1    process 20540     /usr/bin/make     
  (gdb) info thread
    Id   Target Id         Frame 
  * 1    process 20540 "make" (running)
  (gdb) cont
  Continuing.
  Cannot execute this command while the selected thread is running.
  </code></pre>
  
  <p>but the kernel sees it as blocked on <code>ptrace_stop</code>:</p>
  
  <pre><code>$ ps -o "cmd,wchan" -p 20540
  CMD                         WCHAN
  /usr/bin/make check         ptrace_stop
  </code></pre>
  
  <p>... and it makes no progress until <code>gdb</code> is detached, or it's killed. Signals to the process are ignored, and <code>interrupt</code> in <code>gdb</code> has no effect.</p>
  
  <hr>
  
  <p>I'm using <code>GNU gdb (GDB) Fedora 7.7.1-18.fc20</code> on x86_64.</p>