Hello,
I am trying to flush the receive buffer of a pipe created with the
pipe() command, but I’m getting the error: Inappropriate I/O control
operation.
Sample code:
{
int fd[2];
if ( pipe(fd) == -1) perror(“pipe”);
if (tcflush(fd[0], TCIFLUSH) == -1) perror(“tcflush”);
}
Any suggestions?
Thx!
Alain.
Alain Achkar wrote:
I am trying to flush the receive buffer of a pipe created with the
pipe() command, but I’m getting the error: Inappropriate I/O control
operation.
A pipe is not a terminal device, and so does not support that operation.
Any suggestions?
Any data written to a pipe must be read (or is discarded only when
all readers/writers close it). You could loop making a non-blocking
read() of the pipe and discarding data in that manner until EAGAIN.