title: Python subprocess.Popen get pid of the process that forks a process
body: <p>I am firing up an ssh command that will fork itself out and will be running even after the script is done. So the code looks like this:</p>
  
  <pre><code>ssh_proc = Popen(['ssh', '-f', '-N', '-L', local_forward, local_user_host], stdin=PIPE, stdout=PIPE)
  print ssh_proc.pid
  stat = ssh_proc.poll()
  </code></pre>
  
  <p>As you can see <code>ssh -f</code> forks ssh as a process and runs after the script is done - i need to get the pid of that ssh process. The print statement above, will only print out the pid of Popen process. Any suggestions?></p>