Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def child():
- print('\nA new child ', os.getpid())
- os._exit(0)
- def parent():
- while True:
- newpid = os.fork()
- if newpid == 0:
- child()
- else:
- pids = (os.getpid(), newpid)
- print("parent: %d, child: %d\n" % pids)
- reply = input("q for quit / c for new fork")
- if reply == 'c':
- continue
- else:
- break
- parent()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement