import os
print('Process (%s) start...' % os.getpid())
# Only works on Unix/Linux/Mac:
pid = os.fork()#os.fork()创建2个进程,返回值为0时,表示子进程,返回值为子进程号是---父进程os.getpid()表示当前进程
if pid == 0:
print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))
else:
print('I (%s) just created a child process (%s).' % (os.getpid(), pid))
来源:https://www.cnblogs.com/heishanyaoren/p/12194677.html