summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2020-07-10 22:19:08 -0600
committerAndreas Kling <kling@serenityos.org>2020-07-11 11:33:33 +0200
commit7a27fa3df840d71a87a3b1f6904fdc1030f5cba9 (patch)
tree12494e072e91eaa731efb952236677afc649ae1b
parentf4ddca0a73fb2d911a7c068cc38524806ff8d748 (diff)
downloadserenity-7a27fa3df840d71a87a3b1f6904fdc1030f5cba9.zip
LibC: Implement tcflush(3)
-rw-r--r--Kernel/TTY/TTY.cpp8
-rw-r--r--Libraries/LibC/sys/ioctl_numbers.h2
-rw-r--r--Libraries/LibC/termios.cpp4
3 files changed, 11 insertions, 3 deletions
diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp
index a68a0cbeb6..2f1fde1675 100644
--- a/Kernel/TTY/TTY.cpp
+++ b/Kernel/TTY/TTY.cpp
@@ -329,6 +329,14 @@ int TTY::ioctl(FileDescription&, unsigned request, FlatPtr arg)
if (request == TCSETSF)
flush_input();
return 0;
+ case TCFLSH:
+ // Serenity's TTY implementation does not use an output buffer, so ignore TCOFLUSH.
+ if (arg == TCIFLUSH || arg == TCIOFLUSH) {
+ flush_input();
+ } else if (arg != TCOFLUSH) {
+ return -EINVAL;
+ }
+ return 0;
case TIOCGWINSZ:
ws = reinterpret_cast<winsize*>(arg);
if (!current_process.validate_write(ws, sizeof(winsize)))
diff --git a/Libraries/LibC/sys/ioctl_numbers.h b/Libraries/LibC/sys/ioctl_numbers.h
index 8b9491a207..2492349060 100644
--- a/Libraries/LibC/sys/ioctl_numbers.h
+++ b/Libraries/LibC/sys/ioctl_numbers.h
@@ -52,6 +52,7 @@ enum IOCtlNumber {
TCSETS,
TCSETSW,
TCSETSF,
+ TCFLSH,
TIOCGWINSZ,
TIOCSCTTY,
TIOCNOTTY,
@@ -75,6 +76,7 @@ enum IOCtlNumber {
#define TCSETS TCSETS
#define TCSETSW TCSETSW
#define TCSETSF TCSETSF
+#define TCFLSH TCFLSH
#define TIOCGWINSZ TIOCGWINSZ
#define TIOCSCTTY TIOCSCTTY
#define TIOCNOTTY TIOCNOTTY
diff --git a/Libraries/LibC/termios.cpp b/Libraries/LibC/termios.cpp
index 575d8824ed..e1cf4d15ad 100644
--- a/Libraries/LibC/termios.cpp
+++ b/Libraries/LibC/termios.cpp
@@ -60,9 +60,7 @@ int tcflow(int fd, int action)
int tcflush(int fd, int queue_selector)
{
- (void)fd;
- (void)queue_selector;
- ASSERT_NOT_REACHED();
+ return ioctl(fd, TCFLSH, queue_selector);
}
speed_t cfgetispeed(const struct termios* tp)