• 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: Dumping input to NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dumping input to NSTask


  • Subject: Re: Dumping input to NSTask
  • From: John Timmer <email@hidden>
  • Date: Thu, 15 Jul 2004 08:47:39 -0400

Louis -

Thanks so much for your help. This indeed did the trick, and was
substantially faster than writing files in /tmp. I would have thought that
sending the fileHandle a "closeFile" would have done the same thing without
making assumptions about the underlying implementation, but Cocoa's full of
interesting surprises like this.

Along those lines, I found it amusing that this works:
theResults = [[[NSString alloc] initWithData: taskResponseData
encoding: NSUTF8StringEncoding]
autorelease];

But this doesn't:
theResults = [NSString stringWithUTF8String: [taskResponseData bytes]];

Oh well, I'll know who to write if this breaks in Tiger....

Cheers,

John



>
> I hope that there is a better way to accomplish it, but one (very
> unsupported) workaround would be to do this after you finish writing
> all of your data to the standard input pipe:
>
> (you will need to #include "unistd.h")
>
> NSFileHandle *input = [[yourTask standardInput] fileHandleForWriting];
> close([input fileDescriptor]);
> [input setValue:[NSNumber numberWithUnsignedShort:1] forKey:@"_flags"];
>
> This manually closes the fileDescriptor of the NSFileHandle, and then
> changes the flag that NSFileHandle uses to determine if it is
> supposed to close the file descriptor when the NSConcreteFileHandle
> instance is dealloc'ed.

> Hope that helps,
>
> Louis
>








_______________________________________________
This mind intentionally left blank
_______________________________________________
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: Dumping input to NSTask
      • From: "Louis C. Sacha" <email@hidden>
References: 
 >Re: Dumping input to NSTask (From: "Louis C. Sacha" <email@hidden>)

  • Prev by Date: Re: CGDisplayCapture question
  • Next by Date: Re: [options] Cocoa GUI Client to web based SQL database
  • Previous by thread: Re: Dumping input to NSTask
  • Next by thread: Re: Dumping input to NSTask
  • Index(es):
    • Date
    • Thread