[maemo-developers] Check if application is run

From: Eero Tamminen eero.tamminen at nokia.com
Date: Wed Nov 14 19:05:56 EET 2007

ext Aleksandr Koltsoff wrote:
> Michael Stepanov wrote:
>> when the SDL program crashed by some reason to run it again. What is the
>> most efficient way to periodically check something in the Maemo SDK?

If you exec it directly, just use wait/waitpid().  No need for polling.

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

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

> (adding this is not that hard,
> one hooks into the same logic that is used for BSD style process
> accounting, but this isn't present in stock kernel).
> Obviously you'll want to also check the reason why your application
> "crashed" and act on that (branching on the exit code) but that was
> omitted from the above snippets.

For a crazy hack (nothing you would offer for others),
one can install in Chinook a core dump handler (using
'|' in the /proc core pattern).

	- Eero

More information about the maemo-developers mailing list