File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1414import stat
1515import shlex
1616import select
17+ import tempfile
18+ import fcntl
1719
1820try :
1921 import json
@@ -576,6 +578,19 @@ def jsonify(result, format=False):
576578 except UnicodeDecodeError :
577579 return json .dumps (result2 , sort_keys = True , indent = indent )
578580
581+ def log_lockfile (prog ):
582+ # create the path for the lockfile and open it
583+ tempdir = tempfile .gettempdir ()
584+ uid = os .getuid ()
585+ path = os .path .join (tempdir , "%s.lock.%s" % (prig , uid ))
586+ lockfile = open (path , 'w' )
587+ # use fcntl to set FD_CLOEXEC on the file descriptor,
588+ # so that we don't leak the file descriptor later
589+ lockfile_fd = lockfile .fileno ()
590+ old_flags = fcntl .fcntl (lockfile_fd , fcntl .F_GETFD )
591+ fcntl .fcntl (lockfile_fd , fcntl .F_SETFD , old_flags | fcntl .FD_CLOEXEC )
592+ return lockfile
593+
579594if __name__ == '__main__' :
580595 #configvalue = getConfig("./config.ini", "mysql", "port")
581596 #print configvalue
You can’t perform that action at this time.
0 commit comments