From b8ed17b9dad515309f59154fb3c0e0a99fbbf6ac Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 7 May 2021 00:39:08 -0700 Subject: [PATCH] libc/termios: Implement TCSADRAIN and TCSAFLUSH for tcsetattr Signed-off-by: Xiang Xiao Change-Id: If87a4931cd5a55e064f58c19a22c7ce13f538000 --- libs/libc/termios/lib_tcsetattr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/libc/termios/lib_tcsetattr.c b/libs/libc/termios/lib_tcsetattr.c index e93bf584ea..cde1c0663c 100644 --- a/libs/libc/termios/lib_tcsetattr.c +++ b/libs/libc/termios/lib_tcsetattr.c @@ -83,10 +83,15 @@ int tcsetattr(int fd, int options, FAR const struct termios *termiosp) { - if (options == TCSANOW) + if (options != TCSANOW) { - return ioctl(fd, TCSETS, (unsigned long)termiosp); + tcdrain(fd); } - return -ENOSYS; + if (options == TCSAFLUSH) + { + tcflush(fd, TCIFLUSH); + } + + return ioctl(fd, TCSETS, (unsigned long)termiosp); }