From 9c05f75eaa7d8e04c8f67c2cf6840ec9f79940d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Thu, 13 Apr 2023 09:15:01 +0000 Subject: [PATCH] clatd: only wait 15s for SIGTERM during shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test: TreeHugger Bug: 277682237 Signed-off-by: Maciej Żenczykowski Change-Id: If69c00f6f1c3cc1db9f8942852eeb1dbd0b4ab2e --- main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 11da65bec9..f888041c0f 100644 --- a/main.c +++ b/main.c @@ -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); }