Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
data FileLockingNotSupported Source #
Exception thrown by hLock
on non-Windows platforms that don't support
flock
.
Since: base-4.10.0.0
Instances
Exception FileLockingNotSupported Source # | |
Defined in GHC.Internal.IO.Handle.Lock.Common | |
Show FileLockingNotSupported Source # | Since: base-4.10.0.0 |
Defined in GHC.Internal.IO.Handle.Lock.Common |
hLock :: Handle -> LockMode -> IO () Source #
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:
- 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.
- The implementation uses relies on any of a number of locking facilities, depending upon what the platform supports:
LockFileEx
is used on Windows- On platforms that support it we use the
F_OFD_SETLK
andF_OFD_SETLKW
fnctl
s. - Otherwise we use
flock
hence all of their caveats also apply here.
- On non-Windows platforms that don't support
flock
(e.g. Solaris) this function throwsFileLockingNotImplemented
. We deliberately choose to not provide fcntl based locking instead because of its broken semantics.
Since: base-4.10.0.0