1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <unistd.h> #include <termios.h> #include <sys/ioctl.h> #include <asm/errno.h> extern int errno; /* Flush pending data on FD. */ int tcflush(int fd, int queue_selector) { switch (queue_selector) { case TCIFLUSH: return ioctl(fd, TCFLSH, 0); case TCOFLUSH: return ioctl(fd, TCFLSH, 1); case TCIOFLUSH: return ioctl(fd, TCFLSH, 2); default: errno = EINVAL; return -1; } }