title: NSTask termination handler only runs if I send waitUntilExit
body: <p>I have a class that iterates through all the subfolders of a given folder on OSX and sends a message to its delegate for each folder it finds.</p>
  
  <p>For each folder found I want to run an <code>NSTask</code>. So far so good. It's when I specify a <code>terminationHandler</code> to the <code>NSTask</code> that I run into problems. </p>
  
  <p>This is the code:</p>
  
  <pre><code>-(void)crawler:(FTCFileSystemCrawler *)aCrawler
   didFindFolder:(NSURL *)aURL
        withName:(NSString *)aFileName
            stop:(BOOL *)stop{
  
      NSTask *task = [NSTask new];
      task.launchPath = @"/usr/bin/say";
      task.arguments = @[aFileName];
      task.terminationHandler = ^(NSTask *aTask){
          NSLog(@"Terminating!");
          [self.tasks removeObject:aTask];
  
      };
      [self.tasks addObject:task];
  
      [task launch];
      //[task waitUntilExit];
  
  
  }
  </code></pre>
  
  <p>This works fine, it after sending <code>launch</code> to the <code>NSTask</code>, I send <code>waitUntilExit</code>. If I don't, the termination handler never runs.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>PS Please keep in mind that this is just a simple example. I'm actually using this to identify git repos and run a command it it.</p>