gartenriese
gartenriese

Reputation: 4366

Block terminal input while running a terminal program

When I press enter while my terminal program runs, a new line is added. How can I disable this? I don't want to use ncurses. I am on Ubuntu.

Upvotes: 2

Views: 688

Answers (1)

gartenriese
gartenriese

Reputation: 4366

Following up n.m's hint, I found this and came up with this:

static struct termios t;
tcgetattr( STDIN_FILENO, &t);
t.c_lflag &= ~ECHO;
tcsetattr( STDIN_FILENO, TCSANOW, &t);

This seems to block all input to the terminal.

Upvotes: 1

Related Questions