scope {
$file = File\open_read_only(__DIR__.'foo.txt');
using $file->tryLockx(File\LockType::SHARED);
$file->close();
} // __dispose() releases an already released lock
Uncaught exception 'HH\Lib\_Private\_OS\ErrnoException' with message
'Errno 9: Bad file descriptor' in /path/to/vendor/hhvm/hsl-experimental/src/file/Lock.php:29
Stack trace:
#0 /path/to/vendor/hhvm/hsl-experimental/src/file/Lock.php(29): HH\Lib\_Private\_OS\flock()
#1 /path/to/src/start.hack(7): HH\Lib\File\Lock->__dispose()
...
According to the man pages, the lock is already released on file close, so it is releasing the same lock twice, causing an error.
$ man flock | grep -B 1 -A 1 closed
-u, --unlock
Drop a lock. This is usually not required, since a lock is automatically dropped when the file is closed.
However, it may be required in special cases, for example if the enclosed command group may have forked
a background process which should not be holding the lock.
Is this intended behavior?
According to the man pages, the lock is already released on file close, so it is releasing the same lock twice, causing an error.