HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulefilelock-0.1.1.7Haskell2010

System.FileLock

This module provides a portable interface to file locks as a mechanism for inter-process synchronization.

Each file lock is associated with a file. When taking a lock, the assiciated file is created if it's not present, then the file is locked in an OS-dependent way. While the lock is being held, no other process or thread can take it, unless the specified SharedExclusive values allow it.

All locks held by a process are released when the process exits. They can also be explicitly released using unlockFile.

It is not recommended to open or otherwise use lock files for other purposes, because it tends to expose differences between operating systems. For example, on Windows System.IO.openFile for a lock file will fail when the lock is held, but on Unix it won't.

Note on the implementation: currently the module uses flock(2) on non-Windows platforms, and LockFileEx on Windows.

On non-Windows platforms, InterruptibleFFI is used in the implementation to ensures that blocking lock calls can be correctly interrupted by async exceptions (e.g. functions like timeout). This has been tested on Linux.

  • 2 types
  • 5 values
  • Packagefilelock-0.1.1.7
  • Exports7
  • LanguageHaskell2010
  • LicenceLicenseRef-PublicDomain
  • SourceFileLock.hs
datadata FileLock
#

A token that represents ownership of a lock.

Instances1Eq
  • Eq FileLockDefined in filelock-0.1.1.7 · System.FileLock
datadata SharedExclusive
#

A type of lock to be taken.

Constructors

  • Shared

    Other process can hold a shared lock at the same time.

  • Exclusive

    No other process can hold a lock, shared or exclusive.

Instances2Eq, Show