Recently, I am trying to write a simple version of Linux command more. In order to do that, I need to enter noncanonical mode and non-echo mode in the terminal so that I get the input immediately after keypressing and terminal does not show the character I type.
I did it by doing so:
// set the terminal mode
struct termios tm;
tcgetattr(STDIN_FILENO, &old);
tm = old;
tm.c_lflag &= ~(ICANON | ECHO);
tm.c_cc[VMIN] = 1;
tm.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSADRAIN, &tm);
This works when I use arguments like
more test_file
But when I tried to pipe more with other command like
ls /bin | more
The terminal is back to canonical and echo mode. Why does this happen?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)