• 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: Exception reading pipe from NSTask using debugger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception reading pipe from NSTask using debugger


  • Subject: Re: Exception reading pipe from NSTask using debugger
  • From: Jim Ingham <email@hidden>
  • Date: Fri, 11 Mar 2005 09:23:47 -0800

This code worked fine under the debugger on a DP G5 on Tiger.

The debugger will get woken up in this case to handle the SIGCHLD when the ps process dies. You can see this for yourself if you are curious by setting:

(gdb) handle SIGCHLD print

in the Debugger. Now gdb turns right around and hands the SIGCHLD back to the program and sets it running again. But it's possible that in the process of sending the exception and receiving the reply the system had to interrupt the read call.

Usually, you should just retry the read if you get an EINTR, however... I think you are never guaranteed that read calls won't be interrupted, and you are always supposed to loop on (No_Of_Bytes_Read < 0 && errno == EINTR). So I'm not sure Foundation should be throwing an exception here.

You said you found earlier discussion of this, did that mention whether a bug had been filed? If so, did it say the bug number, and if not, can you file one?

Jim

On Mar 11, 2005, at 7:42 AM, James Bucanek wrote:

email@hidden wrote on Thursday, March 10, 2005:

Well, your code runs fine in the scenarios you give on my PB17 1.33GHz,
10.3.8 (no haxies...) so it might be an issue that only shows up on
dual CPU machines. If you have the CHUD tools installed you'll have a
'Hardware' System Preference that can turn off one of your G5's cpus to
see if that makes a difference. The CHUD tools are not installed by
default, but they are located on the Xcode developer tools CD.

I had the CHUD tools installed already, so I turned off one CPU. It didn't make any difference. Maybe it's a G5 issue?


If you know you will always have less data than the socket buffers
(~32K if memory serves) you could try calling -waitUntilExit before
-readDataToEndOfFile.

I don't like to make those kinds of assumptions. I'm sure ps is unlikely to return more than 32K of data, but somewhere in the universe someone is going have a system that does; The app will hang, and I'll get blamed for it. ;)


Regardless, I did try putting the waitUntilExit before the read and it works fine. I also tried using a loop calling availableData, but that did the same thing.

It appears that almost any significant delay between launch and read prevents this from occurring. I would guess some race condition introduced by the debugger, but I haven't a clue as to what it might be.

(Also, in my code I wrap -launch in an exception handler since the
documentation says it can raise an exception if something prevents the
process from running...)

This whole block is wrapped in a NS_DURING block, which is how I was catching the exception. But all that was superfluous to the example, so I left it out.


Thanks for the suggestion.

--
James Bucanek <mailto:email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Exception reading pipe from NSTask using debugger (From: James Bucanek <email@hidden>)

  • Prev by Date: How do I make XCode skip .svn directories on install?
  • Next by Date: Re: Odd gcc error passing reference parameter to function
  • Previous by thread: Re: Exception reading pipe from NSTask using debugger
  • Next by thread: NULL characters?
  • Index(es):
    • Date
    • Thread