Xref: utzoo comp.sys.hp:2232 comp.unix.wizards:16905 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!sdcsvax!ucsdhub!sdsu!mmcp From: mmcp@sdsu.UUCP ( mmcp) Newsgroups: comp.sys.hp,comp.unix.wizards Subject: terminal i/o Keywords: ioctl Message-ID: <3836@sdsu.UUCP> Date: 13 Jun 89 03:48:59 GMT Organization: San Diego State University, Math/Sciences Dept. Lines: 35 Hi folks, I am running UNIX as HP-UX 6.2 on a 9000 series 300 computer; and I am trying to do terminal i/o which requires the ability to flush an input buffer before I post a read. To do this, I am using the following code outline: #include main() { ...stuff fd = open( "/dev/tty", O_RDONLY ); ioctl( fd, TCFLSH, 0 ); /* flush input buffer */ c = getc( stdin ); /* stdin and fd both control terminal */ ...more stuff } Is this enough to do what I want? I have also tried doing this by fdopen()ing a stream off of fd and passing this to fgetc(). I am sometimes getting this to work, but to unpredicatable results. Part of the "stuff" code is a signal handler which is waking up every 500000 milliseconds and incrementing a variable; nothing more. I looked around for ways to flush stdin, and this was all I could come up with after looking at termio(7). Remember, I am trying to erase the characters from the input buffer. I don't want any characters there until I actually post a read. Any help would be appreciated. Syd Logan San Diego State University