[Interest] Detecting if the application is already running from another user account

Murphy, Sean smurphy at walbro.com
Fri Jun 3 16:16:32 CEST 2016


> Thanks for all those suggestions. Of course there are platform specific solutions,
> but I'd like to keep the code 100% cross platform everywhere it's possible.
>
> The issue with file locking, is every OS does not have a system-wide user-writable standard folder.
> There is /tmp on linux/unix which is standard, but AFAIK windows only has
> per-user temporary file, and system temp which is not user writable. 
>
> Also QLocalSocket doesn't do the job under windows, as two processes can listen
> on the same name (only one will receive data), the conflict is not reported by the API.
>
> It seems there is no very good solution.

Just throwing a hacky idea out there, but what about listening on a UDP socket? 
- application launches and listens for x seconds, if it doesn't hear anything it assumes it's the
  only instance and starts broadcasting every 0.5x seconds

There's an obvious race condition if two users start the application almost 
simultaneously not sure how worried about that you are?

Sean


More information about the Interest mailing list