Reading stdin in raw mode

Eric M. Boehm emb978 at leah.Albany.Edu
Sun Mar 26 15:25:16 AEST 1989


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 at ALBNY1VX.BITNET
EMB978 at LEAH.ALBANY.EDU



More information about the Comp.unix.questions mailing list