• 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/NSPipe STDIN hangs on large data...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask/NSPipe STDIN hangs on large data...


  • Subject: Re: NSTask/NSPipe STDIN hangs on large data...
  • From: "Joe Pezzillo" <email@hidden>
  • Date: Wed, 05 Feb 2003 02:35:33 -0700

Daryn-

Thanks for encouraging me to continue to look around and for leading me down
the path that used the UNIX file control commands. Finally (at 2:30am here
in Boulder, Colorado, USA), searching for an explanation for the "resource
temporarily unavailable" exception I was getting after using those UNIX
commands, I found this article:

<http://www.omnigroup.com/mailman/archive/macosx-dev/2001-December/021997.ht
ml>

...which offers further supporting evidence of this problem and includes a
working code fragment of a solution (and from way back in 2001, to boot).

I guess I should have figured that just doing the whole file/pipe handling
in the UNIX realm would sidestep the problems I was experiencing with the
blocking NSFileHandles and NSTask/NSPipe.

Thanks again for all your help!

Joe
email@hidden

cc: Alex Raftis, author of the linked article (THANK YOU!)


On 1/29/03 7:12 PM, "Daryn" <email@hidden> wrote:

> On Wednesday, January 29, 2003, at 06:08 PM, Joe Pezzillo wrote:
>> Of course, I thought that's what "readInBackgroundAndNotify" was
>> supposed to
>> deal with in the first place for the Asynch version.
>
> Once blocked on a write, the run loop will grind to a halt. You might
> try spinning off another thread with the read file handle and have that
> thread read the output. I doubt NSTask is thread-safe, but I wouldn't
> expect any problems with the file handles.
>
>> fileStatus = fcntl([readHandle fileDescriptor], F_SETFL, O_NONBLOCK);
>>
>> ... but then if I try to read right away, I get a "Resource temporarily
>> unavailable" exception. ...
>
> I guess NSFileHandle doesn't like 0-length reads or the EAGAIN error...
> It's rather odd that NSFileHandle doesn't include non-blocking support.
>
>> So then I tried using select() based on its manpage,
>> readyFDs = select( 1, &fdreadset, nil, nil, &zeroTV );
>
> Your first arg to select() is causing only fd 0 (stdin) to be checked.
> Trying passing [readHandle fileDescriptor]+1. I'd recode that into a
> selector like -(BOOL)hasAvailableData to make it more palatable.
>
>> I truly appreciate all the time you've taken to help me with this, your
>> insights are very valuable. If you can suggest a book or online
>> reference
>> for this stuff, I'll gladly devour it and spend another day testing
>> before
>> asking any more questions!
>
> Almost any O'Reilly book is good. It's a bit costly ($70), but if you
> really want to learn unix, I'd told that Richard Steven's Advanced
> Programming in the UNIX Environment is a great book. Also try googling
> for "unix pipe read write deadlock".
>
> Daryn
_______________________________________________
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.

  • Prev by Date: Re: Updated Cocoa documentation available
  • Next by Date: Line ending issues, portability, Project Builder, FileMerger and more...
  • Previous by thread: Re: Updating menu items in a status bar item
  • Next by thread: Line ending issues, portability, Project Builder, FileMerger and more...
  • Index(es):
    • Date
    • Thread