select()ing the STDIN

select()ing the STDIN

Post by James Ledd » Wed, 01 Jan 2003 04:46:29



I have a question,

After polling the stdin for data using the select() function, is it as easy
as using the getchar() function to retrive the data select() has told me
was there?

Also, when using getchar(), am I allowed to just loop, reading characters
into a string, until getting an EOF?

Thanks in advance.

--
-J. Leddy (a.k.a. iustitia)

 
 
 

select()ing the STDIN

Post by Barry Margoli » Wed, 01 Jan 2003 05:34:05




Quote:>After polling the stdin for data using the select() function, is it as easy
>as using the getchar() function to retrive the data select() has told me
>was there?

It's not a good idea to mix stdio functions and Unix I/O system calls.
Stdio is buffered, so select() may wait even though there's data sitting in
the stdio input buffer that could be read.

So if you need to use select() to wait for input, you should use read()
rather than getchar().

Quote:>Also, when using getchar(), am I allowed to just loop, reading characters
>into a string, until getting an EOF?

Of course, why wouldn't you be?

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.