readme prueba
This commit is contained in:
parent
40f5660522
commit
386f0b3572
23
readme.md
23
readme.md
|
@ -1,2 +1,25 @@
|
|||
# Ejemplos de fork() con python
|
||||
|
||||
```python
|
||||
# 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()
|
||||
```
|
Loading…
Reference in New Issue