Changeset 459

Show
Ignore:
Timestamp:
01/22/08 09:53:56 (1 year ago)
Author:
gbooker
Message:

Switch to using nstask instead of fork for the child since the signal handler seems to break the "sleep" mode on the ATV

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SapphireImportHelper.m

    r452 r459  
    4040@end 
    4141 
    42 static void childHandler(int i) 
    43 { 
    44         int status; 
    45         pid_t child; 
    46          
    47         while((child = waitpid(-1, &status, WNOHANG)) > 0); 
    48 } 
    49  
    5042@implementation SapphireImportHelper 
    5143 
     
    180172         
    181173        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(connectionDidDie:) name:NSConnectionDidDieNotification object:nil]; 
    182         /*Handle children crashing*/ 
    183         struct sigaction act; 
    184          
    185         act.sa_handler = childHandler; 
    186         act.sa_flags = SA_NOCLDWAIT; 
    187         sigaction(SIGCHLD,  &act, NULL); 
    188174         
    189175        [self startClient]; 
     
    213199{ 
    214200        NSString *path = [[NSBundle bundleForClass:[SapphireImportHelper class]] pathForResource:@"ImportHelper" ofType:@""]; 
    215         const char *cpath = [path fileSystemRepresentation]; 
    216         int pid = fork(); 
    217         if(pid == 0) 
    218         { 
    219                 const char *argv[2] = {cpath, NULL}; 
    220                 execve(cpath, argv, NULL); 
    221         }        
     201        [NSTask launchedTaskWithLaunchPath:path arguments:[NSArray array]]; 
    222202} 
    223203