Rozumiem że w petli czeka sie na zkan konca linii zeby odgadnac ze stdin jest gotowe do odczytu, ale dlaczego nie wypisuje sie "AAA" umieszczone jeszcze przed petla i przed selectem ?!?!?!?
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
int main(int argc, char * argv[])
{
fd_set readfds;
struct timeval tv;
printf("AAAA");
tv.tv_sec = 10;
tv.tv_usec = 0;
while (1) {
FD_ZERO(&readfds);
FD_SET(STDIN_FILENO, &readfds);
int select_retval = select(STDIN_FILENO+1, &readfds, NULL, NULL, &tv);
if (select_retval < 0) {
perror("select");
} else if (select_retval > 0) {
if (FD_ISSET(STDIN_FILENO, &readfds)) {
printf("stdin");
}
}
}
return 0;
}