Changing the daemon-launch mechanism
To be perfectly honest, I don't remember why this is changed. I changed it over a year ago, and have been running that code ever since, so that must mean it's good.... right?
I know I did have problems with launchd occasionally deciding not to launch NanoFibre under Tiger... maybe this was a workaround for that?
Loading branch information
1 changed file
and 11 deletions.
@@ -9,6 +9,8 @@
import <Carbon/Carbon.h >
import <Cocoa/Cocoa.h >
import "MusicLibrary.h "
import <unistd.h >
int main( int argc, char *argv)
@@ -23,20 +25,22 @@ int main(int argc, char *argv)
- LSApplicationParameters appParams;
version = 0;
flags = kLSLaunchAsync | kLSLaunchDontSwitch | kLSLaunchDontAddToRecents | kLSLaunchAndHide;
application = &appRef;
asyncLaunchRefCon = NULL;
//Tell the app that we want to run in daemon mode. We're using the environment vars to do this, because...
environment = ( CFDictionaryRef)[ NSDictionary dictionaryWithObject: @"yes " forKey: ]; @"fibreDaemon "
// ..."This field is ignored in Mac OS X v10.4". Cheers guys.
argv = NULL;
initialEvent = NULL;
CFURLRef url = CFURLCreateFromFSRef( kCFAllocatorDefault, &appRef);
NSLog( ); @"Couldn't convert fsref to pathname "
NSString* pathName = ( NSString *) CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
NSString* executable = [pathName stringByAppendingString: ]; @"/Contents/MacOS/NanoFibre "
system([[ NSString stringWithFormat: , executable] @"fibreDaemon=yes \" %@ \" " cStringUsingEncoding: NSUTF8StringEncoding]);
sleep( 60); //LaunchD is dumb and kills our daemon if it doesn't stay running for 60 seconds (TODO: Even in Leopard?)