• 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: NSPipe or NSFileHandle buffering?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPipe or NSFileHandle buffering?


  • Subject: Re: NSPipe or NSFileHandle buffering?
  • From: Sherm Pendley <email@hidden>
  • Date: Sun, 1 Dec 2002 11:34:28 -0500

On Sunday, December 1, 2002, at 11:09 AM, mw wrote:

chomp($pop3host = <STDIN>);

This reads a line of input - that is, everything up to and including the next newline.

So it seems that when I am writing information from the Cocoa program to the
Perl program, it buffers everything somewhere between the two programs in
the "pipes", and then writes everything to a single variable, leaving all of
the other Perl variables undefined or empty.

Nothing of the sort. Your Perl script is written to read a line of input at a time, and the parent program is passing everything on a single line.

I tried using this code in the perl program to turn off buffering for STDIN:

select STDIN;
$|=1;

as recommended by several websites,

I sincerely doubt that this is recommended by *any* reputable web sites, as it makes no sense. $| controls buffering on STDOUT - it has no effect whatsoever on STDIN.

but that does nothing since I am not
technically inputting data from the terminal.

The source of the input data is irrelevant. $| does nothing to STDIN because it's not supposed to.

P.S. The Perl program works fine on the command line, so there isn't
anything buggy about the Perl code. Just a heads-up :-).

It works on the command line because each line of input ends with a newline. That's not the same as the input you're passing it via NSTask, which does not include the newlines.

sherm--

If you listen to a UNIX shell, can you hear the C?
_______________________________________________
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.

References: 
 >NSPipe or NSFileHandle buffering? (From: mw <email@hidden>)

  • Prev by Date: Re: NSPipe or NSFileHandle buffering?
  • Next by Date: Re: NSPipe or NSFileHandle buffering?
  • Previous by thread: Re: NSPipe or NSFileHandle buffering?
  • Next by thread: Re: NSPipe or NSFileHandle buffering?
  • Index(es):
    • Date
    • Thread