Why can’t a shared memory file locked by flock() be unlocked automatically when closing the file descriptor?
This snippet is designed to lock a shared memory file by flock()
for 10 seconds and then release the lock. I ran it on two terminals to test if the lock is effective.