Dealing with crash/lockup in critical app?

I’m developing an app that’s controlling hardware, reading probe data and controlling power via relays and it’s pretty critical that this app can’t crash or lock up indefinitely when it’s not attended.

We all know that no app can’t crash or lock up (Unless you’re delusional :smiley: ) so I’m looking for a way to have something watch it, then kill or restart it if one of those things are detected, so barring downright hardware faults there’s an extra layer of security.

I’m thinking something like a watchdog app that runs along side the main app, the main app could even spawn it.

The main app updates a “I’m still alive” file, watchdog checks a date/time stamp and restarts the app if nothing changes inside some interval.

Has anyone dealt with such a situation and perhaps have some pointers?