Bogusław Brandys wrote:
Michael Van Canneyt wrote:



On Wed, 14 Jun 2006, Andreas Berger wrote:

Does Lazarus have a cross-platform way of guaranteeing that only one instance of the program can run? I know how to do this in windows but would like to use a cross-platform approach for my Lazarus apps. It would also be nice (but not necessary) if I could receive a handle or other access method of the first running instance.


You can do the same as on Windows, only the actual calls will differ.

It would be nice to wrap these calls in a component...

Michael.


Good news is that in Turbo Power OnGuard component that I'm porting to fpc/lazarus there is a unit for this.However under linux there is no certain way to do it.It is done by using defined filename but unfortunately there is no way to automatically delete this file on crash.When application crashes this file must be removed manually :-( I have found also situation when mutex used under windows is not released when application hang (this is however rare)

I am not very proficient in *nix, but maybe you can create a lock file with the Process ID (PID) in it. After seeing that there is a lock file, you can ask the system if the a process with that PID exists. Of course PIDs are recycled after a process is closed to theoretically you have a (small) chance that the system says the PID is in use. Maybe you can get some extra information of the process by the PID, i.e. command line or executable, like the info you see in top and or ps. With that info you could make the lock per user or per system.

Vincent.

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to