#include <stdio.h>
#include <termios.h>
#include <unistd.h>

main()
{
	int n;
	char buf;
	struct termios term, save;

	if( tcgetattr( STDIN_FILENO, &save) < 0 ){
		fprintf( stderr, "Get original attributes error!\n");
	}

	term.c_lflag &= ~(ECHO | ICANON);

	term.c_cc[VMIN] = 0;
	term.c_cc[VTIME] = 0;

	if( tcsetattr( STDIN_FILENO, TCSAFLUSH, &term) < 0 ){
		fprintf( stderr, "Set new attributes error!\n");
	}

	while( !(n = read( STDIN_FILENO, &buf, 1)) ) {
		fprintf( stderr, ".");
		usleep(100000);
	}

	write ( STDOUT_FILENO, &buf, 1);

	if( tcsetattr( STDIN_FILENO, TCSAFLUSH, &save) < 0 ){
		fprintf( stderr, "Set new attributes error!\n");
	}
}

