![]() |
How to forbid multi-running an application?
Hi!
I have a computational intensive animation application that I want to run only as a single instance. In other words, if user tries to start the same application again, it should not start. How to do that? Hopefully there is a simple way, though I don't believe so ... |
Re: How to forbid multi-running an application?
This is typically done using lock files. The directory /var/run can be used. Or /tmp for lock files that should not survive a reboot.
As far as I know, there are POSIX defined functions to handle this. Depending on your framework, there might be implementations there too. You could use gconf for ease of use but then you must take into account that it might not be thread safe on the same level as files in the file system. |
Re: How to forbid multi-running an application?
Quote:
Most builtin applications are running with one single instance only. For example you can not open multiple instances of the clock or calculator applications. nicolai |
Re: How to forbid multi-running an application?
Quote:
(Just as I wrote later on in my comment...) |
Re: How to forbid multi-running an application?
Okay, so the cows are still not flying. I mean that there is no simple way like a flag in the .desktop file or something. I have to do it the hard way, as usually. Probably a lock file then... Thank you for the hints! :)
|
Re: How to forbid multi-running an application?
if your app handles DBus request properly, osso should not let it run several times ...
|
Re: How to forbid multi-running an application?
Yes there is a simple way. Launch application via DBus (use .service file) and register application with osso_init(). Documentation is found for example from the wiki.
|
Re: How to forbid multi-running an application?
If you've created an osso_context and have set the X-Osso-Service field in the desktop file correctly, Hildon Desktop will call the "top_application" mehod on an already running instance instead of starting a new one.
|
Re: How to forbid multi-running an application?
In fact, lock file isn't very good: if the program is killed before it exits voluntarily, the lock file may not be deleted. That forbids the program to start any more!
Better way would be to examine process list and check if the binary is already running. How to do that, then? |
Re: How to forbid multi-running an application?
Quote:
|
Re: How to forbid multi-running an application?
Quote:
Instead of bringing an instance that is running in the background forward and back into full screen when the desktop shortcut is touched, it will open a new instance... Not a good thing. This also explains why when it is closed from the minimized state, it doesn't save any changes that were made during the running of that instance. I was hoping that at least the multiple instances problem could be solved by a user hack to the .desktop file. |
Re: How to forbid multi-running an application?
Anyone has any ideas about how to do this with Qt?
|
Re: How to forbid multi-running an application?
Quote:
@Venemo Grab the FreOffice source. It has the QDBus equiv. to all this. |
Re: How to forbid multi-running an application?
Okay, a late post for an old thread: the QtSingleApplication solution from the Qt devs does exactly this.
|
| All times are GMT. The time now is 00:40. |
vBulletin® Version 3.8.8