tcflush
int tcflush(int fd, int queue_selector);
tcflush() discards data written to the object referred to by fd but not transmitted, or data received but not read, depending on the value of queue_selector.
TCIFLUSH
flushes data received but nor read.
TCOFLUSH
flushes data written but not transmitted.
TCIOFLUSH
flushes both data received but not read, and data written but not transmitted.