HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelukko-0.1.2Haskell2010

Lukko

Open Handle based locking

  • 5 types
  • 11 values
  • Packagelukko-0.1.2
  • Exports16
  • LanguageHaskell2010
  • LicenceGPL-2.0-or-later AND BSD-3-Clause
  • SourceLukko.hs
datadata FileLockingMethod
#

Potentially availble lock methods.

Constructors

Instances5Bounded, Enum, Eq, Ord, Show

File descriptors

6 declarations
typetype FD = FD
#

Opaque file descriptor

An int / CInt on unix systems, and HANDLE on windows.

Handles

4 declarations
valuehLock :: Handle -> LockMode -> IO ()
#

If a Handle references a file descriptor, attempt to lock contents of the underlying file in appropriate mode. If the file is already locked in incompatible mode, this function blocks until the lock is established. The lock is automatically released upon closing a Handle.

Things to be aware of:

1) This function may block inside a C call. If it does, in order to be able to interrupt it with asynchronous exceptions and/or for other threads to continue working, you MUST use threaded version of the runtime system.

2) The implementation uses LockFileEx on Windows, open file descriptor locks on Linux, and flock otherwise, hence all of their caveats also apply here.

3) On non-Windows plaftorms that don't support flock (e.g. Solaris) this function throws FileLockingNotImplemented. We deliberately choose to not provide fcntl based locking instead because of its broken semantics.