Reference links:
https://www.cnblogs.com/284628487a/p/5590857.html
----
Code:
#!/usr/bin/python3 import os print("getpid : %d" % os.getpid()) pid = os.fork() if pid == 0 : print("child ! getpid :%d \t getppid() :%d " % (os.getpid(), os.getppid())); else: print("parent ! getpid :%d \t getppid() :%d " % (os.getpid(), os.getppid()));
operation result:
getpid : 20198 parent ! getpid :20198 getppid() :16844 child ! getpid :20199 getppid() :20198