HH\Lib\OS\flock
Acquire or remove an advisory lock on a file descriptor
namespace HH\Lib\OS;
function flock(
FileDescriptor $fd,
int $flags,
): void;
See man 2 flock for details. On error, an ErrnoException will be thrown.
A shared lock can also be 'upgraded' to an exclusive lock, however this operation is not guaranteed to be atomic: systems may implement this by releasing the shared lock, then attempting to acquire an exclusive lock. This may lead to an upgrade attempt meaning that a lock is lost entirely, without a replacement, as another process may potentially acquire a lock between these operations.
Parameters
FileDescriptor $fdint $flagsa bitmask ofLOCK_flags; one out ofLOCK_EX,LOCK_SH, orLOCK_UNmust be specified.
Returns
void