# class KLockFile

###

Module | kdecore
Namespace |
Class | KLockFile
Inherits |

\class KLockFile klockfile.h <KLockFile>

The KLockFile class provides NFS safe lockfiles.

Author Waldo Bastian <bastian@kde.org>

### enums

- LockFlag { NoBlockFlag, ForceFlag }
  typesafe object: LockFlags
- LockResult { LockOK, LockFail, LockError, LockStale }

enum details

### methods

- KLockFile (file, componentName)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  file | QString |
  componentName | KComponentData | KGlobal.mainComponent()

- KLockFile (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |
  a1 | KComponentData | KGlobal.mainComponent()

- getLockInfo ()

  returns bool, int (pid), QString (hostname), QString (appname)

  Argument | Type | Default
  --- | --- | ---

  Returns the pid, hostname and appname of the process holding the lock after the lock functon has returned with LockStale. Returns false if the pid and hostname could not be determined

- isLocked ( )

  returns bool

  Returns whether the lock is held or not

- lock (flags)

  returns KLockFile.LockResult

  Argument | Type | Default
  --- | --- | ---
  flags | KLockFile.LockFlags | KLockFile.LockFlags()

  Attempt to acquire the lock

  flags - A set of LockFlag values OR'ed together.

- setStaleTime (_staleTime)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  _staleTime | int |

  Set the time in seconds after which a lock is considered stale

- staleTime ( )

  returns int

  Return the time in seconds after which a lock is considered stale The default is 30.

- unlock ( )

  returns Nothing

  Release the lock

### enums - detail

- LockFlag { NoBlockFlag, ForceFlag }

  Return immediately, do not wait for the lock to become available

  typesafe object: LockFlags

NoBlockFlag - 1 -
ForceFlag - 2 -

- LockResult { LockOK, LockFail, LockError, LockStale }

  Lock was acquired successfully

  | LockOK | - 0 | - |
  | LockFail | - | - |
  | LockError | - | - |
  | LockStale | - | - |