The way this is typically done is to check in main() for any 
already-running processes, and if present just shut down the newly 
started one.  If you want to be user-friendly, you can give focus to the 
already running version so the user is not left wondering why the app 
didn't start.

One tricky part is that the user may have renamed the executable, so 
don't hard-code the name of your app inside main.  Instead, identify the 
name under which it was started in main().  To be even more fool-proof 
(since the user may rename the executable between the first and second 
invocations), you can create some type of signal (e.g., semaphore) when 
the first instance of the app is run.  Subsequent instances can just 
look for the presence of that signal.

natarajan wrote:
> Hi all,
> Is there a way in GTK+ which I can use to stop users from running 
> multiple instances of an application program. I am looking for this as I 
> want my program to work cross platform, in windows as well as in Linux.
> 
> Many Thanks for your time and response in advance,
> Kind regards,
> 
> Natarajan.
> 


-- 
Guy Rouillier
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to