Re: NSTask and Notification?
Re: NSTask and Notification?
- Subject: Re: NSTask and Notification?
- From: David Dauer <email@hidden>
- Date: Fri, 24 Oct 2003 15:50:06 +0200
"Alastair J.Houghton" <email@hidden> schrieb am 22.10.2003 11:47
Uhr :
>
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.
>
And *how* can i solve that problem? I want use notifications, because the
user should be able to work with my program as long as the task gives
output. How can i detect when the task don't print anything more so that i
can procceed the final output with a function?
Thanks
David
_______________________________________________
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.