Last active
January 2, 2016 06:29
-
-
Save RedHatter/8264094 to your computer and use it in GitHub Desktop.
Attempt to completely fork from parent process.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import time, os, sys | |
# do the UNIX double-fork magic | |
pid = os.fork() | |
if pid > 0: | |
# parent process, exit | |
sleep(5) | |
sys.exit(0) | |
# os.setsid() | |
# do second fork | |
pid = os.fork() | |
if pid > 0: | |
# exit from second parent | |
sleep(10) | |
os._exit(os.EX_OK) | |
# do stuff | |
time.sleep(15) | |
# all done | |
os._exit(os.EX_OK) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment