title: How to attach a process in gdb
body: <p>I have a simple C program that forks a process and then runs an executable. </p>
  
  <p>I want to attach the child process to gdb. </p>
  
  <p>I run the main program in a console and open another console to find the pid of the child process, then I start gdb with the following command:</p>
  
  <pre><code>gdb attach 12271
  </code></pre>
  
  <p>where <code>12271</code> is the child process id, but the attach fails with:</p>
  
  <pre><code>No such file or directory.
  </code></pre>
  
  <p>Any idea why?</p>