正如手册所述
https://www.php.net/manual/en/function.flock.php
On versions of PHP before 5.3.2, the lock is released also by fclose() (which is also called automatically when script finished).
据我了解,自 5.3.2 版以来,锁不会自动释放。那是对的吗?
此外,这会导致问题,如果在脚本执行已被客户端(通过 HTTP 请求或 CLI)中止时释放锁。
holdtom