[Gambas-user] "mutex" applications

tobi tobiasboege01 at ...1601...
Wed Jun 6 14:32:07 CEST 2012


On Wed, 06 Jun 2012, Bruce wrote:
> On Wed, 2012-06-06 at 12:38 +0200, Rolf-Werner Eilert wrote:
> 
> > Hi Bruce,
> > 
> > I have successfully used this code which is from Jussi Lahtinen. I built 
> > it into two of my applications, and it works reliably, at least under 
> > Gambas2 on our somewhat older system:
> > 
> > PUBLIC SUB Form_Open()
> > DIM sOutput AS String
> > 
> >    EXEC ["pgrep", "-f", "-l", "-u", System.User.Name, "Stein3.gambas"] 
> > WAIT TO sOutput
> > 
> >    IF Split(Trim$(sOutput), gb.NewLine).Count > 1 THEN
> >      QUIT
> >    ENDIF
> > 
> > Just replace "Stein3" by your binary's name.
> > 
> > Regards
> > 
> > Rolf
> 
> 
> Nice! A lot quicker than using gb.Desktop.
> 
> 
> Sadly!
> It doesn't solve the problem of activating the desired window.
> 
> And there is a slight "weird", it doesn't detect an instance that is
> running via the IDE.  No idea, but don't really care much, that's not
> the problem.
> 
> Ah well, back to Benoit's dbus suggestion.  Oh, how I hate having to
> learn these "new" techo things.
> 
> Back tomorrow.
> 
> regards
> Bruce  
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

As another possible solution, like firefox once did - when I last used it at least -, is to create a
lockfile and check for that. If you are running, the lockfile exists, when program terminates, it
removes the file. I suggest to deliver a script to remove that lockfile in case of application crash
(I wrote such a thing for the firefox at our school because students seem to either manage to crash
firefox very often or login as the same users all the time).
You can create that file on whatever scope you want it to act in, like per user, e.g. in their home
directories, or system-wide, e.g. in /tmp.

Regards,
Tobi




More information about the User mailing list