In Cygwin, calling Python3 os.execlp()
creates a new process to run external python codes, child's pid is different from that returned by previous os.fork()
.
I do not know why Cygwin have this weird result.
Running Environment :
- Cygwin under win10
- Python 3.6.4
Code :
parent.py
pid = os.fork()
if pid == 0:
os.execlp('python', 'python', 'child.py')
else:
print('child is , ', pid)
child.py
print(os.getpid())
When running parent code in Cygwin, the pid numbers returned by two print
function are different.
# running result $python fork-exec.py
Child is 6104
Hello from child, 9428
This program runs perfectly under Linux platform.