[maemo-developers] Check if application is run

From: Eero Tamminen eero.tamminen at nokia.com
Date: Thu Nov 15 10:24:07 EET 2007

ext Aleksandr Koltsoff wrote:
> Eero Tamminen wrote:
>> ext Aleksandr Koltsoff wrote:
>>> I think in your case it would be sufficient to do something like this:
>>> while true; do
>>>   ./run-your-application params
>>>   sleep 2
>>> done
>>> Or in C:
>>> while(1) {
>>>   system("./run-your-application params");
>>>   sleep(2);
>>> }
>> That would shorten the battery life. If one really needs/wants
>> to kludge things with polling, the interval should be several
>> times larger.
> When the application is running, both methods wait for the process to
> terminate, i.e., no polling. man 3 system. The idea originally was that
> should the application terminate, it will be restarted after a while.

Sorry, I didn't read your mail properly (need to get new glasses
one of these days...), I just saw the "sleep 2".

> If the application is completely broken, and will fail to start in any
> case, then this would amount to polling, and would shorten battery life.

This would happen also if the process daemonizes itself.

> My original post did suggest handling exit codes of the child properly,
> but I guess that was lost somewhere in the process..
>>> Linux (kernel) does not have a non-polling mechanism to track
>>> PID-existance for non-related processes.
>> It has, you just need to be the process parent.  :-)
> Note the "non-related" part :-). Parent <-> child = related processes.

	- Eero

More information about the maemo-developers mailing list