Skip to content

Instantly share code, notes, and snippets.

@mitsuhiko
Created August 29, 2012 14:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mitsuhiko/d55199e9b1ad7fc65504 to your computer and use it in GitHub Desktop.
Save mitsuhiko/d55199e9b1ad7fc65504 to your computer and use it in GitHub Desktop.
import os
import sys
import time
expected = 7340
while True:
child = os.fork()
if child == expected:
break
if child == 0:
if os.getpid() == expected:
break
os._exit(0)
else:
os.waitpid(child, 0)
print child
print 'Keeping process alive after it was found'
time.sleep(100000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment