mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
This is meant to increase the success of downloaded updates from finishing installing on system shutdown. The updater progress app needs to use dispatch source for observing when the PID dies because LaunchServices may no longer be available at this point. Before an update is superceded we will need to send a skip/cancel message to expedite the termination of the helpers.
40 lines
1.4 KiB
Objective-C
40 lines
1.4 KiB
Objective-C
#import <Foundation/Foundation.h>
|
|
#import "AppInstaller.h"
|
|
|
|
|
|
#include "AppKitPrevention.h"
|
|
|
|
int main(int __unused argc, const char __unused *argv[])
|
|
{
|
|
@autoreleasepool
|
|
{
|
|
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
|
|
if (args.count != 4) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
NSString *hostBundleIdentifier = args[1];
|
|
NSString *homeDirectory = args[2];
|
|
NSString *userName = args[3];
|
|
|
|
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostBundleIdentifier:hostBundleIdentifier homeDirectory:homeDirectory userName:userName];
|
|
[appInstaller start];
|
|
|
|
// Ignore SIGTERM because we are going to catch it ourselves
|
|
signal(SIGTERM, SIG_IGN);
|
|
// Ignore SIGPIPE because we won't want read or write failures due to broken pipe to unexpectably
|
|
// terminate the process (e.g, when extracting archives or performing package installs).
|
|
signal(SIGPIPE, SIG_IGN);
|
|
|
|
dispatch_source_t sigtermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue());
|
|
dispatch_source_set_event_handler(sigtermSource, ^{
|
|
[appInstaller handleTerminationRequest];
|
|
});
|
|
dispatch_resume(sigtermSource);
|
|
|
|
[[NSRunLoop currentRunLoop] run];
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|