Flush stdin

Marko Rauhamaa marko at pacujo.net
Wed Oct 22 06:57:28 EDT 2014


Dan Stromberg <drsalists at gmail.com>:

> On Mon, Oct 20, 2014 at 9:41 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> Terminal devices support line buffering on write.
> Yes, though that's not the only place it's useful.
>
>> Line buffering on read is an illusion created by higher-level libraries.
>> The low-level read function reads in blocks of bytes.
>
> Actually, doesn't line buffering sometimes exist inside an OS kernel?
> stty/termios/termio/sgtty relate here, for *ix examples.  Supporting
> code: http://stromberg.dnsalias.org/~strombrg/ttype/  It turns on
> character-at-a-time I/O in the tty driver via a variety of methods for
> portability.  I wrote it in C before I took an interest in Python.

I was being sloppy in my TTY terminology. A TTY device is running inside
the kernel and thus "writes" by copying bytes from its kernel buffer
into the user space when the user space process calls read(2).


Marko



More information about the Python-list mailing list