[comp.unix.questions] Reading stdin in raw mode

emb978@leah.Albany.Edu (Eric M. Boehm) (03/26/89)

I am trying to read stdin in raw mode. I am sending the terminal enquire
string (ESC Z) and trying to read the response. I must be in raw mode
since the response string has no terminating newline. I can do this
with getchar() but getchar() returns no error code if there is nothing to be
read, it just keeps waiting for input. However, if I try to read stdin
with read(2) in nonblocking mode, I am told there is nothing there
(returns -1).

My goal is to be able to read stdin until there are no more characters
left. If I don't read all the characters they pop up on the command line
when the program finishes. I currently read until I get what I know will
be the last character but this seems rather hacked.

Eric M. Boehm
EMB978@ALBNY1VX.BITNET
EMB978@LEAH.ALBANY.EDU