[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Built-in printf Sits Awkwardly with UDP.
From: |
Andre Majorel |
Subject: |
Re: Built-in printf Sits Awkwardly with UDP. |
Date: |
Thu, 21 Jul 2011 10:19:02 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On 2011-07-20 14:34 +0100, Ralph Corderoy wrote:
> No. Here's my understanding of how it currently works. The built-in
> printf works out a character to print at a time; no foresight needed or
> used. It asks the C library to print it with putchar(3). The C library
> can implement buffering to avoid too many expensive write(2) system
> calls. bash has the C library buffer stdout by lines. Each time
> putchar(3) is called the character is appended to the buffer. If the
> character was '\n' or the buffer is now full then write(2) is called to
> pass the buffer to the kernel and the buffer then treated as empty.
>
> When printf is finished the buffer is flushed, e.g. if there's anything
> in it then write(2) is called.
>
> The C library provides two other modes of buffering, see setvbuf(3).
> bash could easily detect that stdout is a regular file, have a new
> stream be duplicated from file descriptor 1, and set it to
> block-buffered.
If standard output is a log file, log entries could remain
latent for a very long time.
The buffering mode we really want is buffered with a forced
flush at reasonable intervals, E.G. one second after the last
write. Unfortunately, there's no such thing in stdio.
--
André Majorel http://www.teaser.fr/~amajorel/
- Re: Built-in printf Sits Awkwardly with UDP., (continued)
- Re: Built-in printf Sits Awkwardly with UDP., Ralph Corderoy, 2011/07/20
- Re: Built-in printf Sits Awkwardly with UDP., Eric Blake, 2011/07/20
- Re: Built-in printf Sits Awkwardly with UDP., Ralph Corderoy, 2011/07/20
- Message not available
- Re: Built-in printf Sits Awkwardly with UDP., Ralph Corderoy, 2011/07/22
- Re: Built-in printf Sits Awkwardly with UDP., Chet Ramey, 2011/07/24
- Re: Built-in printf Sits Awkwardly with UDP., Ralph Corderoy, 2011/07/25
- Re: Built-in printf Sits Awkwardly with UDP., Chet Ramey, 2011/07/25
- Re: bug#9129: Built-in printf Sits Awkwardly with UDP., Jim Meyering, 2011/07/22
- Re: bug#9129: Built-in printf Sits Awkwardly with UDP., Ralph Corderoy, 2011/07/22
- Re: bug#9129: Built-in printf Sits Awkwardly with UDP., Chet Ramey, 2011/07/24
- Re: Built-in printf Sits Awkwardly with UDP.,
Andre Majorel <=
- Re: Built-in printf Sits Awkwardly with UDP., Ben Pfaff, 2011/07/21
- Message not available
- Re: Built-in printf Sits Awkwardly with UDP., Ralph Corderoy, 2011/07/22