# forks child processes until you type 'q' import os, sys def child( ): print 'Hello from child', os.getpid() os._exit(0) # else goes back to parent loop def parent( ): while 1: newpid = os.fork() if newpid == 0 : child() else: print 'Hello from parent', os.getpid(),newpid if raw_input() == 'q': break parent( ) |
原帖由 java8910 于 2009-11-4 10:46 发表
书中继续写道:
Unfortunately, this won't work on Windows in standard Python today; fork is too much at odds with the Windows model, and a port of this call is still in the works (see also this ...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |