The best module for doing such things is subprocess. And the Popen object has a pid attribute (http://docs.python.org/library/subprocess.html#subprocess.Popen.pid)