#include #include #include #include #include struct termios tty, old_tty; main() { int n, flags; char buf[512]; tcgetattr(STDIN_FILENO, &old_tty); tcgetattr(STDIN_FILENO, &tty); tty.c_lflag &= ~ICANON; tcsetattr(STDIN_FILENO, TCSANOW, &tty); #if 1 flags = fcntl(STDIN_FILENO, F_GETFL, 0); flags |= O_NONBLOCK; fcntl(STDIN_FILENO, F_SETFL, flags); #endif /* n = read(STDIN_FILENO, buf, 10); */ n = fread(buf, 1, 10, stdin); printf("Numread: %d\n", n); if(feof(stdin)) printf("EOF\n"); #if 1 flags &= ~O_NONBLOCK; fcntl(STDIN_FILENO, F_SETFL, flags); #endif tcsetattr(STDIN_FILENO, TCSANOW, &old_tty); exit(0); } .