NSPipe itself doesn't require that a run loop be run, but the 
"InBackgroundAndNotify" methods of the associated NSFileHandle objects do.

You receive a zero-length NSData when (and only when) a read encounters EOF.

There is an inherent race between the receipt of the task termination 
notification and getting end-of-file on the output and error pipes.  This race 
is not in Cocoa, it's in the kernel and the interprocess communication 
mechanisms.  You can't rely on having received all of the data by the time you 
are notified of the task termination.

You should separately track when NSTask has posted the termination notification 
and when each pipe has gotten EOF.  Keep looping around the run loop until *all 
three* things have happened.  (In other words, generalize from your "running" 
variable.  You had the right idea but hadn't covered all of the important 
parts.)

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to