Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

/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.

share|improve this answer
Note that /var/run is only for system processes, and is only writable by root & the daemon group. For user-level processes, something like /tmp is more appropriate. – Gordon Davisson Apr 12 '11 at 22:35

Wherever you want to there is no standard place for lock files in Unix. Only the Linux Filesystem Hierarchy Standard provides for /var/loc See Wikipaedia for some examples of the hierarchies used from there is FreeBsd

As for direct OSX references see NSDistributedLock which gives no directions or example of paths to be used and shlock which gives the BSD example in /tmp

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.