I\'m working on a nifty little function:
def startProcess(name, path):
\"\"\"
Starts a process in the background and writes a PID file
returns i
From the documentation at http://docs.python.org/library/subprocess.html:
Popen.pid The process ID of the child process.
Note that if you set the shell argument to True, this is the process ID of the spawned shell.
If shell
is false, it should behave as you expect, I think.
If you were relying on shell
being True
for resolving executable paths using the PATH
environment variable, you can accomplish the same thing using shutil.which instead, then pass the absolute path to Popen instead. (As an aside, if you are using Python 3.5 or newer, you should be using subprocess.run rather than Popen.