Skip to content

Commit

Permalink
Don't clean up update directory when Autoupdate receives SIGTERM (spa…
Browse files Browse the repository at this point in the history
…rkle-project#2479)

Under rare circumstances, if Autoupdate receives SIGTERM while the installer queue is installing an update this could cause potential corruption.
  • Loading branch information
zorgiepoo authored Dec 20, 2023
1 parent 0a92e04 commit b84c1b1
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 b84c1b1

Please sign in to comment.