bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with line buffered IO when no tty


From: Eric Blake
Subject: Re: Problem with line buffered IO when no tty
Date: Thu, 07 Jul 2011 07:21:21 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

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 shell is using standard input and it invokes a command that
also uses standard input, the shell shall ensure that the standard input
file pointer points directly after the command it has read when the
command begins execution. It shall not read ahead in such a manner that
any characters intended to be read by the invoked command are consumed
by the shell (whether interpreted by the shell or not) or that
characters that are not read by the invoked command are not seen by the
shell.

Bash meets this requirement by reading one byte at a time on
non-seekable input, rather than relying on the decision of libc on
whether stdin defaults to fully-buffered or line-buffered.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]