当有多个文件等待锁时,flock 是否维护一个队列?

Does flock maintain a queue when there are multiple files waiting for a lock?

如果有人能帮助我了解 flock 的功能,那就太好了。可以说我有以下情况:

process A opens the lock file, finds it does not exists, so it creates it.
process A acquires the lock
process B opens the lock (finds it already exists)
process B tries to acquire the lock but has to wait-- Wait 1
process C opens the lock (finds it already exists)
process C tries to acquire the lock but has to wait-- Wait 2
process D opens the lock (finds it already exists)
process D tries to acquire the lock but has to wait-- Wait 3

基于上面的场景,有3个进程在等待获取锁。我的问题是,一旦进程 A 释放了锁,等待作业是如何处理的?是先进先出吗?

谢谢, 凯文

我试着用一个有效的示例脚本测试这个场景,我发现等待的作业是随机处理的。