Skip to content

Instantly share code, notes, and snippets.

@Elizaveta239
Created June 25, 2015 11:07
Show Gist options
  • Save Elizaveta239/8cf2164e6421d50d69da to your computer and use it in GitHub Desktop.
Save Elizaveta239/8cf2164e6421d50d69da to your computer and use it in GitHub Desktop.
import os
import time
import threading
def child():
print "Child id: %d" % os.getpid()
while True:
print("Child alive")
time.sleep(1)
def parent():
new_pid = os.fork()
if new_pid == 0:
child()
else:
print "Parent id: %d" % os.getpid()
while True:
print("Parent alive")
time.sleep(1)
t = threading.Thread(target=parent)
t.setDaemon(True)
t.start()
t.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment