Re: line buffered stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there a function that reads stdin without line buffering?

You should set some terminal attr:

  termios oldt;
  [...]
  tcgetattr(STDIN_FILENO,&oldt);
  termios newt = oldt;
  newt.c_lflag &= (~ICANON & ~ECHO);
  tcsetattr(STDIN_FILENO,TCSANOW,&newt);

and restore the old state when you're done:

  tcsetattr(STDIN_FILENO,TCSANOW,&oldt);

If you interrupt your program, you will see no echo, which is annoying. Type - blind mode - at the shell prompt: "reset" (don't worry, it only resets the terminal).

Gnome-terminal also clears the scrollback buffer upon "reset".
--
ern0.scene.plus4.amiga.code.muzak
Haben Sie Fragen?

--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux