Quote:
So with you, the process that got the lock are differents???
Yes, all of the processes eventually grab the lock. However, the same process has a very good chance of grabbing the lock every time until it reaches the max tries on the loop. The reason for this is that when a process releases the lock it loops and immediately tries to get the lock again. Unless one of the other processes loops at exactly the same time, the process that just released the lock will acquire the lock again.
Try adding a
sleep 5 immediately after the lock is released. This will allow one of the other processes to grab the lock before the process that just released the lock loops and tries again. This probably isn't necessary in a real script where after getting the lock and updating the counter, the script goes off and does something that would take time rather than just looping to try to lock again.
Hope this makes sense.