On Mon, 2020-06-08 at 17:40 +0200, Oliver Neukum wrote: > > Am Montag, den 08.06.2020, 11:39 +0000 schrieb Joakim Tjernlund: > > > Most terminal programs I use tries to empty the read queue after open, just to avoid > > old garbage så I don't see a problem here. It it up to the terminal app. > > Maybe one could use O_DIRECT for this purpose ? > > Well, we can throw away stuff received until some time in open(2). > But you can always have stuff in the buffer when open(2) returns. > User space needs to be ready to deal with stuff in the buffer. User space already does this, but the automatic ECHOing that happens at open is not possible to address in user space. The buffered chars are sent to both the terminal app(putty/minicom etc.) and over the wire to the shell waiting there and that is the problem. There is no way to prevent that ECHO back over the wire(USB) as the default is to ECHO and one have to open the tty to change to non ECHO. Jocke