Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.programmer > #1204
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: How to automatically flush stdout when a read from stdin occurs. |
| Date | 2011-09-03 09:08 +0100 |
| Message-Id | <pan.2011.09.03.08.08.15.887000@nowhere.com> |
| Newsgroups | comp.unix.programmer |
| References | <500542b0-0d1d-4f96-9c17-2d77aacfd1b9@k29g2000yqf.googlegroups.com> <c_adndActqH6LvzTnZ2dnUVZ_o-dnZ2d@posted.internetamerica> |
| Organization | Zen Internet |
On Fri, 02 Sep 2011 23:56:07 -0500, Gordon Burditt wrote: >> but how can I get the >> >> read from stdin causes flush of stdout >> >> behaviour? > > Read the specification of the feature, preferably in any standard > if there is such a standard. I think it goes like this: > > A read from *any unbuffered or line-buffered stream* causes > a flush of *all line-buffered streams*. ISO C says (§7.19.3#3): When a stream is unbuffered, characters are intended to appear from the source or at the destination as soon as possible. Otherwise characters may be accumulated and transmitted to or from the host environment as a block. When a stream is fully buffered, characters are intended to be transmitted to or from the host environment as a block when a buffer is filled. When a stream is line buffered, characters are intended to be transmitted to or from the host environment as a block when a new-line character is encountered. Furthermore, characters are intended to be transmitted as a block to the host environment when a buffer is filled, when input is requested on an unbuffered stream, or when input is requested on a line buffered stream that requires the transmission of characters from the host environment. Support for these characteristics is implementation-defined, and may be affected via the setbuf and setvbuf functions. POSIX (§2.5) says essentially the same thing: When a stream is "unbuffered", bytes are intended to appear from the source or at the destination as soon as possible; otherwise, bytes may be accumulated and transmitted as a block. When a stream is "fully buffered", bytes are intended to be transmitted as a block when a buffer is filled. When a stream is "line buffered", bytes are intended to be transmitted as a block when a <newline> byte is encountered. Furthermore, bytes are intended to be transmitted as a block when a buffer is filled, when input is requested on an unbuffered stream, or when input is requested on a line-buffered stream that requires the transmission of bytes. Support for these characteristics is implementation-defined, and may be affected via setbuf() and setvbuf(). http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
Back to comp.unix.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
How to automatically flush stdout when a read from stdin occurs. tm <thomas.mertes@gmx.at> - 2011-09-02 02:20 -0700
Re: How to automatically flush stdout when a read from stdin occurs. Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-09-02 13:50 +0100
Re: How to automatically flush stdout when a read from stdin occurs. tm <thomas.mertes@gmx.at> - 2011-09-03 02:10 -0700
Re: How to automatically flush stdout when a read from stdin occurs. Nobody <nobody@nowhere.com> - 2011-09-03 13:05 +0100
Re: How to automatically flush stdout when a read from stdin occurs. Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-02 20:43 -0400
Re: How to automatically flush stdout when a read from stdin occurs. gordonb.j3p91@burditt.org (Gordon Burditt) - 2011-09-02 23:56 -0500
Re: How to automatically flush stdout when a read from stdin occurs. Nobody <nobody@nowhere.com> - 2011-09-03 09:08 +0100
csiph-web