Waiting for input with timeout
Must reset timeout
select() is allowed to modify your timeout value.  So for your program, what happens is that the first call to select() takes 0.1 seconds because of the timeout, but the timeout is then reduced to 0.  The next 99999 calls to select() have a zero timeout.  You should reset the timeout right before you call select(), like this:
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
select(STDIN_FILENO+1, &amp;s, NULL, NULL, &amp;timeout);

Once you do that, you no longer need 100000 iterations, because each iteration will have the proper 0.1 second timeout instead of returning &quot;immediately&quot;.