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

alexander golks alex at golks.de
Mon Jun 6 07:47:20 CEST 2016


Am Fri, 3 Jun 2016 14:16:32 +0000
schrieb "Murphy, Sean" <smurphy at walbro.com>:

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

what about keeping a server listening all the runtime?
this would block the port for listening for the next program, which you can capture and handle as needed.

-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160606/466f1011/attachment.sig>


More information about the Interest mailing list