Skip to content

Commit

Permalink
give pid files safe permissions. fixes #293.
Browse files Browse the repository at this point in the history
  • Loading branch information
xcolour committed Dec 11, 2012
1 parent d245f44 commit 8cf9df5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def daemonize(self):
atexit.register(self.delpid) # Make sure pid file is removed if we quit
pid = str(os.getpid())
try:
file(self.pidfile,'w+').write("%s\n" % pid)
fp = os.fdopen(os.open(self.pidfile, os.O_RDWR | os.O_CREAT | os.O_APPEND, 0644), 'w+')
fp.write("%s\n" % pid)
fp.close()
os.chmod(self.pidfile, 0644)
except Exception, e:
msg = "Unable to write pidfile: %s" % self.pidfile
logger.exception(msg)
Expand Down

0 comments on commit 8cf9df5

Please sign in to comment.