clatd: only wait 15s for SIGTERM during shutdown

Test: TreeHugger
Bug: 277682237
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If69c00f6f1c3cc1db9f8942852eeb1dbd0b4ab2e
This commit is contained in:
Maciej Żenczykowski 2023-04-13 09:15:01 +00:00
commit 9c05f75eaa

8
main.c
View file

@ -194,8 +194,12 @@ int main(int argc, char **argv) {
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);
}