参考リンク:
https://www.cnblogs.com/284628487a/p/5590857.html
----
コード:
#!は/ usr / binに/のpython3の インポートOS プリント( "GETPIDた:%d" %のos.getpid()) PID = os.fork() PIDの場合== 0: 印刷( "子GETPID:!%D \トンgetppid ():%のD "%(os.getpid()、os.getppid()))。 他: プリント( "親GETPID:%D \トンgetppid():!%dの" %(os.getpid()、os.getppid()));
結果:
GETPID:20198 親を!GETPID:20198 getppid():16844 子!GETPID:20199 getppid():20198