title: How to determine pid of process started via os.system
body: <p>I want to start several subprocesses with a programm, i.e. a module <code>foo.py</code> starts several instances of <code>bar.py</code>.</p>
  
  <p>Since I sometimes have to terminate the process manually, I need the process id to perform a kill command.</p>
  
  <p>Even though the whole setup is pretty “dirty”, is there a good pythonic way to obtain a process’ <code>pid</code>, if the process is started via <code>os.system</code>?</p>
  
  <p><code>foo.py:</code></p>
  
  <pre><code>import os
  import time
  os.system("python bar.py \"{0}\ &amp;".format(str(argument)))
  time.sleep(3)
  pid = ???
  os.system("kill -9 {0}".format(pid))
  </code></pre>
  
  <p><code>bar.py:</code></p>
  
  <pre><code>import time
  print("bla")
  time.sleep(10) % within this time, the process should be killed
  print("blubb")
  </code></pre>