2008年9月10日水曜日

fork version

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク

import select
import time
import os

r, w = os.pipe()
pid = os.fork()
if pid:
i, o, e =select.select([r],[], [], 3)
assert not o
assert not e
if i:
print 'done! with ', os.read(r, 1000)
else:
print 'time out'
else:
time.sleep(2)
os.write(w, '1000')

0 件のコメント: