fix(app): add global uncaught exception handler for clean restart
Individual thread crashes silently kill the thread without bringing down the process. The half-dead process stays alive but broken, and the service.sh restart loop never fires. Install a default uncaught exception handler that logs the error and calls exitProcess(0), triggering the restart loop for full recovery.
This commit is contained in:
@@ -14,6 +14,7 @@ import org.matrix.TEESimulator.interception.keystore.Keystore2Interceptor
|
|||||||
import org.matrix.TEESimulator.interception.keystore.KeystoreInterceptor
|
import org.matrix.TEESimulator.interception.keystore.KeystoreInterceptor
|
||||||
import org.matrix.TEESimulator.logging.SystemLogger
|
import org.matrix.TEESimulator.logging.SystemLogger
|
||||||
import org.matrix.TEESimulator.util.AndroidDeviceUtils
|
import org.matrix.TEESimulator.util.AndroidDeviceUtils
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main application object for TEESimulator. This object manages the application's lifecycle,
|
* Main application object for TEESimulator. This object manages the application's lifecycle,
|
||||||
@@ -32,6 +33,11 @@ object App {
|
|||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler { thread, throwable ->
|
||||||
|
SystemLogger.error("Uncaught exception on thread '${thread.name}'. Exiting for restart.", throwable)
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
|
|
||||||
SystemLogger.info("Welcome to TEESimulator!")
|
SystemLogger.info("Welcome to TEESimulator!")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user