title: Is there any way to tell gdb to wait for a process to start and attach to it?
body: <p>I have a process that is called by another process which is called by another process and so on ad nauseum.  It's a child process in a long tool chain.</p>
  
  <p>This process is crashing.</p>
  
  <p>I would like to catch this process in gdb to understand why it's crashing.  However, the only way I can think of is:</p>
  
  <ol>
  <li>start the original parent process in the commandline.</li>
  <li>poll <code>ps -C &lt;name process I want to catch&gt;</code> and get the PID.</li>
  <li>launch gdb, attached to that process's PID.</li>
  </ol>
  
  <p>This is cumbersome but usually does the job.  The problem is that the current failure runs very quickly, and by the time I capture the PID and launch gdb, it's already passed the failure point.</p>
  
  <p>I would like to launch gdb and instead of:</p>
  
  <pre><code>(gdb) attach &lt;pid&gt;
  </code></pre>
  
  <p>I would like to do:</p>
  
  <pre><code>(gdb) attach &lt;process name when it launches&gt;
  </code></pre>
  
  <p>Is there any way to do this?</p>
  
  <hr>
  
  <p>I am using gdb 7.1 on linux</p>