From 7a7fb9ecd9e074fa347c7064fa9979a5e8ccd001 Mon Sep 17 00:00:00 2001 From: Zorg Date: Tue, 19 Dec 2023 19:49:36 -0800 Subject: [PATCH] Don't clean up update directory when Autoupdate receives SIGTERM (#2479) Under rare circumstances, if Autoupdate receives SIGTERM while the installer queue is installing an update this could cause potential corruption. --- Autoupdate/main.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Autoupdate/main.m b/Autoupdate/main.m index 96645bca..51636ed4 100644 --- a/Autoupdate/main.m +++ b/Autoupdate/main.m @@ -28,7 +28,11 @@ int main(int __unused argc, const char __unused *argv[]) dispatch_source_t sigtermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue()); dispatch_source_set_event_handler(sigtermSource, ^{ - [appInstaller cleanupAndExitWithStatus:SIGTERM error:nil]; + // Don't clear the update directory because the installer may be in middle of installing an update + // We still need to set an event handler for receiving SIGTERM though, otherwise our job may not terminate + // (This is also recommended from the developer documentation). + // Simply exit with SIGTERM if we recieve this signal + exit(SIGTERM); }); dispatch_resume(sigtermSource);