Skip to content

Instantly share code, notes, and snippets.

@liluo
Forked from jinuljt/singleapp.py
Last active August 29, 2015 14:21
Show Gist options
  • Save liluo/c8cfe24c7890179c3772 to your computer and use it in GitHub Desktop.
Save liluo/c8cfe24c7890179c3772 to your computer and use it in GitHub Desktop.
import fcntl
import time
import sys
lock = file('singleapp.lock', "w+")
try:
fcntl.lockf(lock, fcntl.LOCK_EX|fcntl.LOCK_NB)
except Exception, e:
print "kill me before start again"
sys.exit(0)
while(1):
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment