Cross-platform single instance

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Cross-platform single instance

Felipe Monteiro de Carvalho
Hello,

I was looking into a way to detect if an instance of my application is
running. Is there a cross-platform solution on rtl or fcl?

It seams that semaphores would be a good solution. I took a look at
pthreads and PSemaphore but that is only an alias for unix specific
semaphores.

If there is no current solution for this problem, may I implement
pthreads for Windows? Or maybe a new unit? I remember using Mutex
Windows APIs to do what I need in the past. There are probably
Semaphore functions that could be used to provide a uniform interface
across the supported platforms.

thanks,
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross-platform single instance

Vincent Snijders
Felipe Monteiro de Carvalho schreef:

> Hello,
>
> I was looking into a way to detect if an instance of my application is
> running. Is there a cross-platform solution on rtl or fcl?
>
> It seams that semaphores would be a good solution. I took a look at
> pthreads and PSemaphore but that is only an alias for unix specific
> semaphores.
>
> If there is no current solution for this problem, may I implement
> pthreads for Windows? Or maybe a new unit? I remember using Mutex
> Windows APIs to do what I need in the past. There are probably
> Semaphore functions that could be used to provide a uniform interface
> across the supported platforms.
>

Have you considered UniqueInstance?
http://wiki.lazarus.freepascal.org/UniqueInstance

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross-platform single instance

Luiz Americo Pereira Camara-2
Vincent Snijders wrote:

> Felipe Monteiro de Carvalho schreef:
>> Hello,
>>
>> I was looking into a way to detect if an instance of my application is
>> running. Is there a cross-platform solution on rtl or fcl?
>>
>> It seams that semaphores would be a good solution. I took a look at
>> pthreads and PSemaphore but that is only an alias for unix specific
>> semaphores.
>>
>> If there is no current solution for this problem, may I implement
>> pthreads for Windows? Or maybe a new unit? I remember using Mutex
>> Windows APIs to do what I need in the past. There are probably
>> Semaphore functions that could be used to provide a uniform interface
>> across the supported platforms.
>>
>
> Have you considered UniqueInstance?
> http://wiki.lazarus.freepascal.org/UniqueInstance
>
The updated version can be found at
https://svn.bountysource.com/luipack/trunk/uniqueinstance

Requires fpc 220.

Can work both in Lazarus app or console app.

It works both in Linux (Tested Ubuntu Feisty) and Windows (Tested Xp SP2).

I will prepare a new release in ASAP.

Luiz


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross-platform single instance

Felipe Monteiro de Carvalho
cool, looks pretty good =)

Nevertheless, it would still be useful to have a cross-platform
interface for semaphores.

thanks,
--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Cross-platform single instance

Luiz Americo Pereira Camara-2
In reply to this post by Luiz Americo Pereira Camara-2
Luiz Americo Pereira Camara wrote:
> Vincent Snijders wrote:
>> Have you considered UniqueInstance?
>> http://wiki.lazarus.freepascal.org/UniqueInstance
>>
> The updated version can be found at
> https://svn.bountysource.com/luipack/trunk/uniqueinstance

I released a new version. Look in
http://wiki.lazarus.freepascal.org/UniqueInstance to info how to grab it

Luiz
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal