[Gambas-user] Avoiding multiple instances
Benoit Minisini
gambas at ...1...
Thu Jan 31 12:45:42 CET 2008
On jeudi 31 janvier 2008, Jeffrey Cobb wrote:
> I've made a small toolbar app to run in fluxbox. I've included the
> binary in my xinitrc file. But I'd like to know how I can avoid
> multiple instances of the same app running. How does a gambas program
> detect another copy of itself running?
>
> Jeff
>
It does not. There is no simple way for doing that, because "avoiding multiple
instances" have different meanings on Linux.
1) The first meaning is not having multiple instances on the same OS. You can
do that by using a file lock on a file system that is unique for this OS.
This is what system services usually do.
2) The second meaning is not having multiple instances on the same OS for one
user. You can use a lock file in the user home directory, or one lock file
for each user in the /tmp directoy (because some special users may not have
an home directory).
3) The third meaning is not having multiple instances on the same X11 display
for one client (and usually for one user as multiple users are rarely allowed
to connect to the same X11 display). Then you have to detect the current
running application by looking at top-level windows X11 properties, or by
creating your own X11 property on the root window for your application.
You can do 1) and 2) in Gambas, but 3) cannot be done yet. Implementing 3) in
the gb.desktop component would be a good idea, I note that in the TODO file.
Regards,
--
Benoit Minisini
More information about the User
mailing list