8.1 fork関数の例 import sys, os, time glob = 6 buf = "a write to stdout\n" STDOUT_FILENO = sys.stdout.fileno() def main(): global glob var = 88 # automatic variable on the stack os.write(STDOUT_FILENO, buf) # we don't flush stdout print "before fork" pid = os.fork() if pid == 0: # child glob += 1 # modify variables var += 1 else: # parent time.sleep(2) print "pid={0}, glob={1}, var={2}".format(os.getp