does the real work of releasing the FileLock
435790
private boolean releaseFileLock() {

        // Note:  Closing the super class RandomAccessFile has the
        //        side-effect of closing the file lock's FileChannel,
        //        so we do not deal with this here.
        boolean success = false;

        if (this.fileLock == null) {
            success = true;
        } else {
            try {
                this.fileLock.release();

                success = true;
            } catch (Exception e) {}
            finally {
                this.fileLock = null;
            }
        }

        return success;
    }
840236
def release(self):
		
		if self._locked is True:
			self._locked = False
			self._lock.release()
1176377
def release_lock(self, force=False):
        
        if self.readonly:
            raise exc.ReadOnlyDatabase()
        if self._locked or force:
            self.log.debug("Removing lock file: {0}".format(self.lockfile))
            if os.path.exists(self.lockfile):
                os.remove(self.lockfile)
                self._locked = False
        else:
            self.log.debug("Database not locked (not removing)")
1173744
def acquire(self):
        
        try:
            self._lock_fd = os.open(self._lock_filename, os.O_CREAT | os.O_EXCL)
        except OSError:
            return False
        return True
731528
def close(self):
    
    if not self._is_open:
      raise IOError('Not opened.')

    if not self._is_cached:
      close_file_object = True
    elif self._resolver_context.ReleaseFileObject(self):
      self._is_cached = False
      close_file_object = True
    else:
      close_file_object = False

    if close_file_object:
      self._Close()
      self._is_open = False
1095430
function releaseMutex($filename) {
		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
		fclose($this->fplock[md5($filename)]);
		unset($this->fplock[md5($filename)]);
		if (! $ret) {
			$this->debug("Not able to release lock for $filename");
		}
		return $ret;
	}
1186834
def _is_locked(self):
        '''
        
        '''
        if os.path.isfile(self._lck):
            try:
                import psutil
            except ImportError:
                return True #Lock file exists and no psutil
            #If psutil is imported
            with open(self._lck) as f:
                pid = f.read()
            return True if psutil.pid_exists(int(pid)) else False
        else:
            return False
1334995
def lock_file(filename, interval=.5, timeout=15):
    '''
    
    '''
    log.trace('Attempting to obtain lock for %s', filename)
    lock = filename + '.lock'
    start = time.time()
    while True:
        if os.path.exists(lock):
            if time.time() - start >= timeout:
                log.warning('Unable to obtain lock for %s', filename)
                return False
            time.sleep(interval)
        else:
            break

    with salt.utils.files.fopen(lock, 'a'):
        pass
6236
def unlock(self):
        
        logger.debug("Releasing lock %s", self.lock_file)
        self._lock.release()
        try:
            os.unlink(self.lock_file)
        except FileNotFoundError:
            pass
1215812
boolean isLocked(Path lockFile) throws JobLockException {
    try {
      return this.fs.exists(lockFile);
    } catch (IOException e) {
      throw new JobLockException(e);
    }
  }
1306578
public void unlock() throws IOException {
    if (fileLock != null) {
      try {
        fileLock.release();
      } catch (ClosedChannelException e) {
      }
      fileLock = null;
    }
  }
520709
function unlock()
    {
        if ( $fp = $this->fp() )
        {
            fclose( $fp );
            @unlink( $this->MetaFileName );
            @unlink( $this->FileName );
            $GLOBALS['eZMutex_FP_' . $this->FileName] = false;
        }
        return false;
    }
712204
private boolean aquireFileLock() {

        // PRE:
        //
        // raf is never null and is never closed upon entry.
        //
        // Rhetorical question to self: How does one tell if a RandomAccessFile
        // is closed, short of invoking an operation and getting an IOException
        // the says its closed (assuming you can control the Locale of the error
        // message)?
        //
        final RandomAccessFile lraf = super.raf;

        // In an ideal world, we would use a lock region back off approach,
        // starting with region MAX_LOCK_REGION, then MAX_NFS_LOCK_REGION,
        // then MIN_LOCK_REGION.
        //
        // In practice, however, it is just generally unwise to mount network
        // file system database instances.  Be warned.
        //
        // In general, it is probably also unwise to mount removable media
        // database instances that are not read-only.
        boolean success = false;

        try {
            if (this.fileLock != null) {

                // API says never throws exception, but I suspect
                // it's quite possible some research / FOSS JVMs might
                // still throw unsupported operation exceptions on certain
                // NIO classes...better to be safe than sorry.
                if (this.fileLock.isValid()) {
                    return true;
                } else {

                    // It's not valid, so releasing it is a no-op.
                    //
                    // However, we should still clean up the referenceand hope
                    // no previous complications exist (a hung FileLock in a
                    // flaky JVM) or that gc kicks in and saves the day...
                    // (unlikely, though).
                    this.releaseFileLock();
                }
            }

            if (isPosixManditoryFileLock()) {
                try {
                    Runtime.getRuntime().exec(new String[] {
                        "chmod", "g+s,g-x", file.getPath()
                    });
                } catch (Exception ex) {

                    //ex.printStackTrace();
                }
            }

            // Note: from FileChannel.tryLock(...) JavaDoc:
            //
            // @return  A lock object representing the newly-acquired lock,
            //          or <tt>null</tt> if the lock could not be acquired
            //          because another program holds an overlapping lock
            this.fileLock = lraf.getChannel().tryLock(0, MIN_LOCK_REGION,
                    false);

            // According to the API, if it's non-null, it must be valid.
            // This may not actually yet be the full truth of the matter under
            // all commonly available JVM implementations.
            // fileLock.isValid() API says it never throws, though, so
            // with fingers crossed...
            success = (this.fileLock != null && this.fileLock.isValid());
        } catch (Exception e) {}

        if (!success) {
            this.releaseFileLock();
        }

        return success;
    }
1219491
private static function lockProcess($name)
    {
        $fileName = static::getLockFileName($name);
        $fp = fopen($fileName, 'w+');
        if(false === $fp)
        {
            return false;
        }
        if(!flock($fp, LOCK_EX | LOCK_NB))
        {
            fclose($fp);
            return false;
        }
        static::$lockMap[$name] = [
            'fileName'  => $fileName,
            'fp'        => $fp,
        ];
        return true;
    }
1320397
def close(self):
        """"""
        
        if self.filepath is not None:
            if path.isfile(self.filepath+'.lock'):
                remove(self.filepath+'.lock')
            self.filepath = None
            self.read_only = False
            self.lock()
            return True
        else:
            raise KPError('Can\'t close a not opened file')
304851
public static final void useFileLocking(boolean useFileLocking)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "useFileLocking", new Boolean(useFileLocking));

        _useFileLocking = useFileLocking;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "useFileLocking");
    }
1117472
def release(self):
        """"""
        if not self.acquired:
            raise threading.ThreadError("Unable to release an unacquired"
                                        " lock")
        try:
            self.unlock()
        except IOError:
            self.logger.exception("Could not unlock the acquired lock opened"
                                  " on `%s`", self.path)
        else:
            self.acquired = False
            try:
                self._do_close()
            except IOError:
                self.logger.exception("Could not close the file handle"
                                      " opened on `%s`", self.path)
            else:
                self.logger.log(_utils.BLATHER,
                                "Unlocked and closed file lock open on"
                                " `%s`", self.path)