def write_pid_or_exit(self):
self.pf = open(self.pidfile, 'w+r')
pf = self.pf
fd = pf.fileno()
fcntl.fcntl(fd, fcntl.F_SETFD,
fcntl.fcntl(fd, fcntl.F_GETFD, 0)
| fcntl.FD_CLOEXEC)
try:
pid = os.getpid()
logger.debug('write pid:' + str(pid))
pf.truncate(0)
pf.write(str(pid))
pf.flush()
except Exception as e:
logger.exception('write pid failed.' + repr(e))
sys.exit(0)
评论列表
文章目录