Page 1 of 1

Prevent an activity from launching more than once?

PostPosted: Wed Mar 04, 2009 8:02 pm
by stevenkan
My son is 5, and he doesn't quite seem to grok switching amongst open applications yet. He _always_ goes back to the Home screen and then launches his desired activity, and he never quits them. This causes memory problems, and some apps (like the maze game) just refuse to run if launched a second time.

Is there a way to
1) Prevent an activity from launching a second time, and
2) Automagically switch to the already-running instance if such an attempt is made?

Thanks!

Re: Prevent an activity from launching more than once?

PostPosted: Thu Mar 05, 2009 1:30 pm
by ektoric
Unfortunately, no. The applications themselves have to be "self aware" in this scenario. There's no practical way for Sugar to do the work. Each application would have to do something to wave its hand and say "hey! I'm here!", and each successive start would have to do the right thing and look for that waving.

Re: Prevent an activity from launching more than once?

PostPosted: Thu Mar 05, 2009 2:05 pm
by stevenkan
Interesting. Do you know do other OSes manage this? For example XP will permit multiple instances of Excel (but complain about certain files being locked), but OS X will not.

Does anyone else consider this to be a legitimate problem? Or is it just me :D

Re: Prevent an activity from launching more than once?

PostPosted: Thu Mar 05, 2009 2:41 pm
by ektoric
Other OSes don't manage this. Exactly per your example, it's the application that has to have the smarts. When you launch your second excel, it has to determine whether to start a new window or reselect the currently open excel.

Well, excel is actually a poor example because it's so beefy that it does actually have a very large communication backend, and that is why if you go to program manager and kill "excel", all your excel windows go away. But perhaps that is a good example. Again, it's excel that has to have the smarts built into it, and not the OS.

Re: Prevent an activity from launching more than once?

PostPosted: Thu Mar 05, 2009 2:47 pm
by stevenkan
I learn something new every day :D

So if the application has to handle this, does Sugar allow inter-application communication? Or is each app completely sandboxed?

I suppose an app could write a flag or file to the Journal or some other thing, but that gets messy, especially if apps crash.

Re: Prevent an activity from launching more than once?

PostPosted: Tue Mar 10, 2009 3:53 am
by ektoric
I learn something every day too! Not too long ago, on these very boards, I learned about the OLPC Bitfrost approach to application security. There are different methods of interprocess communication, but bitfrost will certainly put a hamper on things.

Re: Prevent an activity from launching more than once?

PostPosted: Tue Aug 18, 2009 4:21 am
by manymny
each activity has a process identifiable by its filename, that name is easy to obtain- it's easy to see if a named process is already running.

it would be trivial (?) to create a wrapper process that only called an activity if it wasn't running already. sugarizing that wrapper (giving it an icon like the activity it wraps) is a little beyond me, the key perhaps is to do it in python, whereas i would only know where to begin using the bash shell.