• 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 and child process buffering.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask and child process buffering.


  • Subject: Re: NSTask and child process buffering.
  • From: Chris Gehlker <email@hidden>
  • Date: Thu, 21 Feb 2002 09:22:20 -0700

On 2/21/02 7:34 AM, "Ondra Cada" <email@hidden> wrote:

> Chris,
>
>>>>>>> Chris Gehlker (CG) wrote at Wed, 20 Feb 2002 22:35:23 -0700:
> CG> So far there is nothing mysterious. By IDE is blocking because Ruby
> CG> hasn't flushed it's buffers. Where it gets mysterious is that few Ruby
> CG> programs bother with the flush and they work from the command line.
>
> It's not that mysterious, I guess. I dunno Ruby, but I presume it uses
> stdio, does it not?

Yep. It does by default.
> Well, stdio AFAIK automatically flushes line-wise when the output goes into
> a terminal, and does not otherwise. That's all.

So that's it. I had no idea that stdio was magic in this way. I'm new to
unix.

> CG> So my question is "How does tcsh get child processes to turn off
> CG> buffering
>
> It does not, it's the other way round: the child process checks whether it
> prints into a terminal (tcsh has nothing to do with that particularly), and
> behaves accordingly.

Thanks for satisfying my curiosity. I was really bugged by this.
> CG> and how do I replicate that in an NSTask?
>
> You have to fake being a terminal. Though, I am afraid I don't know how to
> -- I've never needed that myself :(

I just figured out any easy way to fake it before reading my mail. No matter
what program the user types in the IDE, I prepend it with

$stdout.sync= true.

This makes Ruby flush the buffer linewise.

It still would be interesting to know how to make an NSPipe fake being a
terminal.

Thanks again for responding. It was very helpful.
--
We ought not to treat living creatures like shoes or household belongings,
which when worn with use we throw away. -Plutarch, biographer (c. 46-120)
_______________________________________________
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: 
 >Re: NSTask and child process buffering. (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: NSThread question
  • Next by Date: Re: Very strange build errors (warning...long)
  • Previous by thread: Re: NSTask and child process buffering.
  • Next by thread: Re: NSTask and child process buffering.
  • Index(es):
    • Date
    • Thread