Files
Saddle-Drone-Client/fork_test.py
2021-04-21 16:17:55 -04:00

22 lines
407 B
Python

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()