From a0e7d39c442717f486caa9438c535488d7388b99 Mon Sep 17 00:00:00 2001 From: DennisEckerskorn Date: Thu, 3 Oct 2024 18:58:18 +0200 Subject: [PATCH] Upload ej01 content --- ej01.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ej01.py b/ej01.py index e69de29..353afb8 100644 --- a/ej01.py +++ b/ej01.py @@ -0,0 +1,20 @@ +# fork solo funciona en unix/macos +import os + +def padre(): + while True: + newpid = os.fork() + if newpid == 0: + hijo() + else: + pids = (os.getpid(), newpid) + print("Padre: %d, Hijo: %d\n" % pids) + reply = input("Pulsa 's' si quieres crear un nuevo proceso") + if reply != 's': + break + +def hijo(): + print('\n>>>>>>>>>> Nuevo hijo creado con el pid %d a punto de finalizar<<<<<' % os.getpid()) + os._exit(0) + +padre() \ No newline at end of file