Advertisement
d1cor

fork_zombie_main.py

Apr 24th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. import os, time, subprocess
  2.  
  3. def hijo():
  4.     print("soy el hijo")
  5.     time.sleep(1)
  6.     os._exit(0)
  7.  
  8.  
  9. def main():
  10.     ret=os.fork()
  11.  
  12.     if ret==0:
  13.         hijo()
  14.  
  15.     print("soy el padre")
  16.  
  17.     #hacerlo primero con ps solo, para ver el defunct
  18.     print(subprocess.check_output(["ps", "fax"], universal_newlines=True))
  19.     time.sleep(2)
  20.     print("_________________________________________________________________")
  21.     print(subprocess.check_output(["ps", "fax"], universal_newlines=True))
  22.     os.wait()
  23.     print("=================================================================")
  24.     print(subprocess.check_output(["ps", "fax"], universal_newlines=True))
  25.  
  26.  
  27. if __name__ == "__main__":
  28.     main()
  29.  
  30. # https://tmate.io/t/ro-wiQTQ107mJbCWajwnEWDB2nkk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement