[Toybox] [PATCH] microcom, stty: Use TCSADRAIN to set tty device attribute

Yi-Yo Chiang yochiang at google.com
Mon Jun 3 04:45:15 PDT 2024


Yes, for _microcom_ 2043855a4bd5 is sufficient for my use cases.

However I think _stty_ should also use TCSADRAIN/TCSANOW to not discard
data. _stty_ flushing and discarding data is surprising to me, because none
of the other stty implementations do this AFAIK (coreutils, freebsd ...).
The https://pubs.opengroup.org/onlinepubs/9699919799/utilities/stty.html
says `stty` should "set of report" termios, it doesn't specify "how" the
termios should be set, nor does it say pending data should/shouldn't be
flushed.

On Fri, May 31, 2024 at 11:08 PM Rob Landley <rob at landley.net> wrote:

> On 5/20/24 23:43, Yi-Yo Chiang via Toybox wrote:
> > Don't flush the tty device input queue when setting device attribute.
> >
> > Rationale:
> >   * microcom: The tty device might already have a _good enough_ termios
> >     to read data from. Flushing the input queue just to set the terminal
> >     attribute would result in data loss in this case.
> >   * stty: This command doesn't read nor write data to the tty device, so
> >     flushing the input queue doesn't make sense here. The program
> >     actually talking to the tty should decide if it wants the tty
> >     flushed or not.
> >     Note: other implementations of stty also uses TCSANOW (bsd) or
> >     TCSADRAIN (coreutils), so I think this assumption is fine.
>
> Was commit 2043855a4bd5 sufficient or do you still have a use case that
> needs
> this? (Email dated the 20th containing a patch dated the 21st vs a git
> commit
> applied the 23rd...)
>
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20240603/a3cd0d63/attachment.htm>


More information about the Toybox mailing list