Thanks, you are right, this variant is better. I made a new variant with all the requested changes.
`asm/termbits.h` don't provide some important functions:
- I use `TCFLSH` ioctl instead of `tcflush`, as in glibc: https://github.com/bminor/glibc/blob/d370155b9ab73d0c45bf968b7a9c823f4697a50... - I use `TCXONC` ioctl instead of `tcflow`, as in glibc: https://github.com/bminor/glibc/blob/d370155b9ab73d0c45bf968b7a9c823f4697a50... - I use `TCSBRK` ioctl instead of `tcdrain`, as in glibc: https://github.com/bminor/glibc/blob/d370155b9ab73d0c45bf968b7a9c823f4697a50...
Termios2 is a Linux-only thing and I assume that directly using Linux-syscalls in this case is okay.
In other cases, I just replace tcgetattr/tcsetattr/termios to TCGETS2/TCSETS2/termios2, because structures are compatible by fields.