From 91cd0e5d1718d973a6bb64ec5decc301828f0a15 Mon Sep 17 00:00:00 2001 From: DennisEckerskorn Date: Thu, 3 Oct 2024 19:07:25 +0200 Subject: [PATCH] Upload ej02.py --- ej02.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ej02.py diff --git a/ej02.py b/ej02.py new file mode 100644 index 0000000..ce9e02b --- /dev/null +++ b/ej02.py @@ -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() \ No newline at end of file