I am trying on os.fork function using CPython 3.7.2
Here is the example
def main():
data = 222
childPid = os.fork()
if childPid == -1:
print('error on fork child')
elif childPid == 0:
data *= 3
else:
time.sleep(3)
print("PID=%d data=%d" % (os.getpid(), data))
When I use C language, I always get 2 continuous PID for parent and child.
However in python, I always get PID which are not continuous( for example here I got 21475 and 21442).
PID=21475 data=666
PID=21442 data=222
Don't understand how it behave not same.