[maemo-developers] Check if application is run

From: Aleksandr Koltsoff czr at iki.fi
Date: Wed Nov 14 22:15:58 EET 2007
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.

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.
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.


More information about the maemo-developers mailing list