Take an exclusive kernel lock on the open file fd without blocking. True when this process now
holds it, false when another open file does. flock(2) on Linux and macOS; on Windows
LockFileEx on one byte at 1 GiB, past any content, so readers of the file are never blocked.
Either way the system releases it when the holder's last handle closes, including at its death.
Take an exclusive kernel lock on the open file
fdwithout blocking. True when this process now holds it, false when another open file does.flock(2)on Linux and macOS; on WindowsLockFileExon one byte at 1 GiB, past any content, so readers of the file are never blocked. Either way the system releases it when the holder's last handle closes, including at its death.