Reputation: 297
I understand the fork function.I know that it duplicates the parent process and after the fork function has been called the parent complete its execution and the child start its execution. Here is a python code the fork a child process
import os
pid, master_fd =os.forkpty()
if pid == 0:
print ('child')
else:
print ('parent')
Why is the word child doesn’t get printed??
Upvotes: 0
Views: 790
Reputation: 168626
The word "child" doesn't appear because os.forkpty()
creates a new pseudo-terminal and routes the child's output to it.
Your understanding would be correct if you had used os.fork()
instead.
Upvotes: 2