commit f3d7abf757e935d6a380f30326537c7f2c00441d Author: Eric Date: Fri Oct 20 18:43:57 2023 +0200 Upload EjercicioPs2Python diff --git a/README.md b/README.md new file mode 100644 index 0000000..5c32644 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Ejercicio PS2 Python + +~~~ text +Nuevo hijo creado 24353 +Padre: 24352, Hijo: 24353 + +Pulsa 's' si quieres crear un nuevo proceso +~~~ diff --git a/ps2.py b/ps2.py new file mode 100644 index 0000000..72cab95 --- /dev/null +++ b/ps2.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