title: How to detect whether an OS X application is already launched
body: <p>Normally an application bundle on OS X can only be started once, however by simply copying the bundle the same application can be launched twice. What's the best strategy to detect and stop this possibility? </p>
  
  <p>On Windows this effect can simply be achieved by the application creating a named resource at launch and then exit if the named resource can't be created, indicating that another process is running that has already created the same resource. These resources are released in a reliable way on Windows when the application quits. </p>
  
  <p>The problem I have seen when researching this is that the APIs on OS X keep state in the file system and thus makes the strategy used on windows unreliable, i.e lingering files after an improper exit can falsely indicate that the application is already running.</p>
  
  <p>The APIs I can use to achieve the same effect on OS X are: posix, carbon and boost.</p>
  
  <p>Ideas?</p>