`/var/lock` equivalent on OSX

compatibilityunix

/var/lock doesn't exist in OSX, so where do the lock files / PID files go?

Best Answer

/private/var/run is the place for system/root level pid files to live on OSX (Darwin)

Locking is more complicated (or simple depending on your POV) with the system/API arbitrating device locks rather than writing them to the filesystem.

Do consider the implications of fast user switching and the documentation on Multiple User Environments or simply calling NSTemporaryDirectory if your locking happens in user space or the application can be fired up more than one at a time.