From mboxrd@z Thu Jan 1 00:00:00 1970 From: tobias@gambas-buch.de (Tobias Boege) Date: Tue, 8 Jan 2013 20:53:44 +0100 Subject: how to flush stdin buffer in linux In-Reply-To: References: Message-ID: <20130108195344.GA530@aurora> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Tue, 08 Jan 2013, Niroj Pokhrel wrote: > Hi all, > I tried to use fflush(stdin) in gcc as I used to in other compilers. But It > didn't clear my buffer so I am wondering how can I clear the stdin buffer > in GCC. > I tried using lseek but got -EPIPE (as tty devices doesn't support lseek > operation). > Thanx in advance. If it's a tty, you may want to use tcflush(fd, TCIFLUSH); Regards, Tobi