lukko: File locking

[ concurrency, library, system ] [ Propose Tags ]

This package provides access to platform dependent file locking APIs:

  • Open file descriptor locking on Linux (Lukko.OFD)

  • flock locking on unix platforms (Lukko.FLock)

  • Windows locking LockFileEx (Lukko.Windows)

  • No-op locking, which throws exceptions (Lukko.NoOp)

  • Lukko module exports the best option for the target platform with uniform API.

There are alternative file locking packages:

  • GHC.IO.Handle.Lock in base >= 4.10 is good enough for most use cases. However, uses only Handles so these locks cannot be used for intra-process locking. (You should use e.g. MVar in addition).

  • filelock doesn't support OFD locking.

Lukko means lock in Finnish.

Submodules Lukko.OFD, Lukko.Windows etc are available based on following conditions.

if os(windows)
  cpp-options: -DHAS_WINDOWS_LOCK

elif (os(linux) && flag(ofd-locking))
  cpp-options: -DHAS_OFD_LOCKING
  cpp-options: -DHAS_FLOCK

elif !(os(solaris) || os(aix))
  cpp-options: -DHAS_FLOCK

Lukko.FLock is available on not (Windows or Solaris or AIX). Lukko.NoOp is always available.


Manual Flags


Enable open file descriptor locking. Available on Linux (kernel 3.15, released Jun 8, 2014).


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS] 0.1, 0.1.1,,,
Dependencies base (>=4.5 && <4.14) [details]
License GPL-2.0-or-later AND BSD-3-Clause[multiple license files]
Maintainer Oleg Grenrus <>
Category System, Concurrency
Source repo head: git clone
Uploaded by phadej at 2019-11-02T12:32:39Z
Distributions Arch:, Fedora:, LTSHaskell:, NixOS:, Stackage:, openSUSE:
Reverse Dependencies 5 direct, 11 indirect [details]
Downloads 19461 total (176 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-11-02 [all 1 reports]