clatd: only wait 15s for SIGTERM during shutdown
Test: TreeHugger
Bug: 277682237
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If69c00f6f1c3cc1db9f8942852eeb1dbd0b4ab2e
diff --git a/main.c b/main.c
index 11da65b..f888041 100644
--- a/main.c
+++ b/main.c
@@ -194,8 +194,12 @@
if (running) {
logmsg(ANDROID_LOG_INFO, "Clatd on %s waiting for SIGTERM", uplink_interface);
- while (running) sleep(60);
- logmsg(ANDROID_LOG_INFO, "Clatd on %s received SIGTERM", uplink_interface);
+ // let's give higher level java code 15 seconds to kill us,
+ // but eventually terminate anyway, in case system server forgets about us...
+ // sleep() should be interrupted by SIGTERM, the handler should clear running
+ sleep(15);
+ logmsg(ANDROID_LOG_INFO, "Clatd on %s %s SIGTERM", uplink_interface,
+ running ? "timed out waiting for" : "received");
} else {
logmsg(ANDROID_LOG_INFO, "Clatd on %s already received SIGTERM", uplink_interface);
}