Skip to content

Commit

Permalink
Don't clean up update directory when Autoupdate receives SIGTERM (#2479)
Browse files Browse the repository at this point in the history
Under rare circumstances, if Autoupdate receives SIGTERM while the installer queue is installing an update this could cause potential corruption.
  • Loading branch information
zorgiepoo committed Dec 20, 2023
1 parent 4ad2b0d commit 7a7fb9e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Autoupdate/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7a7fb9e

Please sign in to comment.