Q&A: What are lockfiles?

Q I have noticed that in OS X’s ~/Library/Preferences there are now zero-length .lockfile documents to match many .plist files. What are these?

A These .lockfile shadows of Property Lists are not actually files (as you have noticed, they occupy no space) but work like locks in a database: when the application owning a Property List is running and the .plist file is open, the lockfile is set to prevent any other application from writing to that Property List.

When nothing has the .plist file open, the lockfile allows other apps to write to the plist.

Although these were introduced with OS X Lion and continue to be used in El Capitan, they are important on any multi-user system, and have security benefits too, in stopping most malware from tampering with Property Lists.

Updated from the original, which was first published in MacUser volume 28 issue 18, 2012.