Upload ej02.py

This commit is contained in:
Dennis Eckerskorn 2024-10-03 19:07:25 +02:00
parent a0e7d39c44
commit 91cd0e5d17
1 changed files with 18 additions and 0 deletions

18
ej02.py Normal file
View File

@ -0,0 +1,18 @@
from multiprocessing import Process
import os
def hijo():
print("Padre: %d, Hijo: %d\n" % ( os.getppid(),os.getpid()))
os._exit(0)
def padre():
while True:
p = Process(target=hijo)
p.start()
print ("\nNuevo hijo creado " , p.pid)
p.join()
reply = input("Pulsa 's' si quieres crear un nuevo proceso\n")
if reply != 's':
break
if __name__ == '__main__':
padre()