• 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 stealth bug in readDataOfLength!! :(
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask stealth bug in readDataOfLength!! :(


  • Subject: Re: NSTask stealth bug in readDataOfLength!! :(
  • From: Alastair Houghton <email@hidden>
  • Date: Wed, 25 Oct 2006 21:23:40 +0100

On Oct 25, 2006, at 8:49 PM, Theodore H. Smith wrote:

On 25 Oct 2006, at 20:28, Stephen Deken wrote:

If it's a perfectly good API, then why did Alastair say this:

Ok. It's a perfectly good API that has at least one bug. Actually, if it really is a SIGCHLD or SIGPIPE that's causing it, it's more properly a 'gotcha', since it's working as designed but trips up lots of developers. If this is the problem, you can mask the signals out during the call and get on with it.

A better solution might be to set the signal in question so that the system call is automatically restarted by using the SA_RESTART flag with sigaction(). Or to just write the read() call directly yourself, which I think is what we did.


Err... OK. That'd be a new one to me. Also too late as I already got a solution using system() and using the > operator to pipe to a file.

You might consider popen() as an alternative to using a temporary file.

I have to say, though, that the Cocoa API is *a lot* more convenient than the usual little dance with fork(), exec(), pipe(), dup2() (and possibly close(), maybe a few others too depending on what you're doing exactly). The fault here is in NSFileHandle I think rather than the task API.

The other thing I remember doing wrong a few times with the NSTask API is passing [inPipe fileHandleForReading] or [outPipe fileHandleForWriting] to the methods that set up the input/output redirection. You are, of course, supposed to just pass the NSPipe objects directly, and if you don't you can get some odd behaviour. That could probably be highlighted better in the docs, as it's quite an important point.

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NSTask stealth bug in readDataOfLength!! :( (From: "Theodore H. Smith" <email@hidden>)
 >Re: NSTask stealth bug in readDataOfLength!! :( (From: "Theodore H. Smith" <email@hidden>)
 >Re: NSTask stealth bug in readDataOfLength!! :( (From: "Stephen Deken" <email@hidden>)
 >Re: NSTask stealth bug in readDataOfLength!! :( (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: New ManagedObject with relationship problem
  • Next by Date: Re: NSTimer question: How to fire at second 00, 05, 10 etc ?
  • Previous by thread: Re: NSTask stealth bug in readDataOfLength!! :(
  • Next by thread: Re: NSTask stealth bug in readDataOfLength!! :(
  • Index(es):
    • Date
    • Thread