Python os.fork() 的问题
发布网友
发布时间:2022-04-20 05:56
我来回答
共2个回答
热心网友
时间:2022-04-19 01:22
➜ ~ cat test.py
import os
for i in range(0,2):
print "i=", i
procid = os.fork()
print "hello"
➜ ~ python test.py
i= 0
hello
i= 1
hello
hello
i= 1
hello
hello
hello
➜ ~ lsb_release -a
No LSB moles are available.
Distributor ID:Ubuntu
Description:Ubuntu 16.04.2 LTS
Release:16.04
Codename:xenial
热心网友
时间:2022-04-19 02:40
6次啊
#!/usr/bin/python
import os
for i in range(2):
print 'i=',i,
procid=os.fork()
print 'hello'
[willie@localhost pys]$ python osfork.py
i= 0 hello
i= 0 hello
i= 1 hello
i= 1 hello
i= 1 hello
i= 1 hello
[willie@localhost pys]$