• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask and Notification?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSTask and Notification?
      • From: David Dauer <email@hidden>
References: 
 >Re: NSTask and Notification? (From: "Sailesh Agrawal" <email@hidden>)

  • Prev by Date: Re: Convert Arrays
  • Next by Date: Re: detecting a double click ahead of time
  • Previous by thread: Re: NSTask and Notification?
  • Next by thread: Re: NSTask and Notification?
  • Index(es):
    • Date
    • Thread