Re: NSTask and Notification?
Re: NSTask and Notification?
- Subject: Re: NSTask and Notification?
- From: "Alastair J.Houghton" <email@hidden>
- Date: Wed, 22 Oct 2003 10:47:40 +0100
On Tuesday, October 21, 2003, at 09:40 pm, Sailesh Agrawal wrote:
One thing I don't understand, do you want the output all at once when
the
process terminates or continuously ?? In the code below, getOutput
gets
called each time the task flushes stdout. If you're only interested in
the final output then listen for the NSTaskDidTerminateNotification
notification instead of NSFileHandleReadCompletionNotification. Then
just do [[theTask standardOutput] readDataToEndOfFile].
*That* won't work! What happens if the process you've started fills-up
the pipe's buffers? The process will be blocked, and because you
aren't emptying the buffer until it terminates (which it can't do,
because it's blocked), you've got a deadlock.
When using pipes, you should always read all of the output from the
process as it arrives, which is what the code David sent appears to do.
Looking at the code, I would expect to get more than one alert panel
on the screen if the process you started in your NSTask outputs any
substantial amount of data, because you continue to call
-readInBackgroundAndNotify as long as you are receiving data.
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.