On Windows, it's common practice to create a named mutex and use the presence of that to determine that an instance of a given app is already running. This has its drawbacks, but mostly works.
I can think of a ways to do this on the Mac:
- named pthread mutexes
- enumerate running processes and look for one that matches
- create and lock a file
Is there something built into Cocoa/Carbon that's easier than the options above? If not, which of the three are most used on the mac? I would assume 2 or 3...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…