Problem with line buffered IO when no tty

2011-07-07 Thread Steven W. Orr
I have a problem with whether things should or should not be line buffered vs. fully buffered. Here's the deal: #! /bin/bash sleep 6 cat <&2 And two more to stderr EOF exit 22 When I run this program, it does what it's supposed to do. I get two lines of output going to stdout (after 6 second

Re: Problem with line buffered IO when no tty

2011-07-07 Thread Andreas Schwab
"Steven W. Orr" writes: > But, I actually do get line buffered IO. No, you don't. > I get the stdout stuff as it happens, and the stderr stuff when that > happens. Every process flushes its output when it exits. > If you run this program locally, it does the same thing. BUT! if you > run it r

Re: Problem with line buffered IO when no tty

2011-07-07 Thread Steven W. Orr
On 7/7/2011 8:48 AM, Andreas Schwab wrote: "Steven W. Orr" writes: But, I actually do get line buffered IO. No, you don't. I get the stdout stuff as it happens, and the stderr stuff when that happens. Every process flushes its output when it exits. If you run this program locally, it d

Re: Problem with line buffered IO when no tty

2011-07-07 Thread Eric Blake
On 07/07/2011 06:55 AM, Steven W. Orr wrote: > So, why is it that bash is behaving like it is always line buffered or > unbuffered, even if there is no console? Because POSIX requires 'sh' to behave like it is unbuffered: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html When the

Re: Problem with line buffered IO when no tty

2011-07-07 Thread Steven W. Orr
On 7/7/2011 9:21 AM, Eric Blake wrote: On 07/07/2011 06:55 AM, Steven W. Orr wrote: So, why is it that bash is behaving like it is always line buffered or unbuffered, even if there is no console? Because POSIX requires 'sh' to behave like it is unbuffered: http://pubs.opengroup.org/onlinepubs