Don Hatch (hatch++at++hell.engr.sgi.com)
Wed, 23 Jun 1999 18:36:24 -0700
Not off topic at all! You need to know how to do this
to get keyboard input in any Performer simulation loop.
Use select() to query whether stdin (fileno = 0) has characters
waiting to be read.
If it says yes, then you should be able to call getc()
or fgets() to get a line of input without it blocking.
You'll have to experiment with the details of stdio buffering
(e.g. what happens when there's more than one line of input waiting?
I suspect the second line might get buffered and so you'll get fooled
into thinking it's not there).
You can probably avoid this issue by calling setbuf(stdin, NULL),
or use read() directly instead of the buffered stdio calls.
Don
-- Don Hatch hatch++at++sgi.com (650) 933-5150 Silicon Graphics, Inc.
This archive was generated by hypermail 2.0b2 on Wed Jun 23 1999 - 18:36:54 PDT