I'm using something similar to the below code, and it seems to work correctly when under launchd control. However, information on creating Foundation-based Objective-C daemons is hard to find and I'm worried I'm missing something, or (worse) on the wrong track entirely.
Can anyone offer any tips or guidance? Thanks. ---- Karl Moskowski <[EMAIL PROTECTED]> Voodoo Ergonomics Inc. <http://voodooergonomics.com/> // daemon.m #import <Foundation/Foundation.h> #import <signal.h> #import "AnObject.h" #import "MyObserver.h" void handleSignal (int signal) { NSLog(@"Shutting daemon down"); AnObject * anObject = [[AnObject alloc] init]; [anObject doCleanup];[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"DaemonHasShutDown" object:nil userInfo:nil options:NSNotificationPostToAllSessions];
exit(EXIT_SUCCESS);
}
int main (int argc, const char * argv[]) {
signal (SIGTERM, handleSignal);
signal (SIGINT, handleSignal);
AnObject * anObject = [[AnObject alloc] init];
if (![AnObject doSetup])
exit(EXIT_FAILURE);
NSLog(@"Daemon running");
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:@"DaemonIsRunning" object:nil userInfo:nil
options:NSNotificationPostToAllSessions];
[[MyObserver sharedInstance] beginObserving];
[[NSRunLoop currentRunLoop] run];
return EXIT_SUCCESS;
}
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
