Hi all,

Thanks for all the advice about how to make my pipe reads non- blocking, that works almost perfectly. I have a class now that handles the notifications (called msgTarget in the code snippet below). The puzzle here is the meaning of "waitUntilExit". My hdiutil info task was returning no data in both the output and error file handles. When I put in sleep(1), I started to get error strings, but no output strings. When I increased the wait to sleep(3), my standard output started coming through. Why would this be the case if waitUntilExit is actually waiting until the hdiutil task completes and exits? Is there some other latency in this process that my sleep() accounts for? I'd rather not rely on a kludge like this to get my output string. Is the problem using readToEndOfFileInBackgroundAndNotify instead of readInBackgroundAndNotify? I tried the latter call, but seem to get better results using readToEndOfFileInBackgroundAndNotify (or is that totally the wrong thing to do?).


                                        [task 
setLaunchPath:@"/usr/bin/hdiutil"];
                                        [task setArguments:[NSArray 
arrayWithObjects:@"info", nil]];
                                        [task 
setStandardError:messagePipeError];                               
                                        [task 
setStandardOutput:messagePipeOutput];                             
NSFileHandle* readHandleError = [messagePipeError fileHandleForReading];
                                        [msgTarget 
setReadHandleError:readHandleError];
NSFileHandle* readHandleOutput = [messagePipeOutput fileHandleForReading];
                                        [msgTarget 
setReadHandleOutput:readHandleOutput];
                                        [readHandleError 
readToEndOfFileInBackgroundAndNotify];
                                        [readHandleOutput 
readToEndOfFileInBackgroundAndNotify];
                                        [task launch];
                                        sleep(3);
                                        [task waitUntilExit];
                                        status = [task terminationStatus];

Thanks for your help,
Michael

Michael Domino
[email protected]



Attachment: 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]

Reply via email to