main.py:
from subprocess import Popen
import sys
proc = Popen([sys.executable, 'sub.py'])
print('parent thinks subprocess pid is', proc.pid)
sub.py:
import os
print('subprocess thinks its pid is', os.getpid())
Output of python main.py on Linux:
parent thinks subprocess pid is 338
subprocess thinks its pid is 338
Output on Windows:
parent thinks subprocess pid is 17340
subprocess thinks its pid is 7308
Why is this?
Edit: print(sys.executable) gives C:\my-venv\Scripts\python.exe