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 $fd
int $flags
a bitmask ofLOCK_
flags; one out ofLOCK_EX
,LOCK_SH
, orLOCK_UN
must be specified.
Returns
void