if (m_tty_fd >= 0) {
// save tty config for restore.
tcgetattr(m_tty_fd, &m_tty_attr);
struct ::termios termdata;
tcgetattr(m_tty_fd, &termdata);
// record the original mode so we can restore it again in the destructor.
::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
// setting this tranlation mode is even needed in INPUT mode to prevent
// the shell from also interpreting codes, if the process has a tty
// attached: e.g. Ctrl+C wouldn't copy, but kill the application.
::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
// set the tty layer to pass-through
termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
termdata.c_oflag = 0;
termdata.c_cflag = CREAD | CS8;
termdata.c_lflag = 0;
termdata.c_cc[VTIME]=0;
termdata.c_cc[VMIN]=1;
cfsetispeed(&termdata, 9600);
cfsetospeed(&termdata, 9600);
tcsetattr(m_tty_fd, TCSANOW, &termdata);
if (m_tty_fd >= 0) {
// save tty config for restore.
tcgetattr(m_tty_fd, &m_tty_attr);
struct ::termios termdata;
tcgetattr(m_tty_fd, &termdata);
// record the original mode so we can restore it again in the destructor.
::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
// setting this tranlation mode is even needed in INPUT mode to prevent
// the shell from also interpreting codes, if the process has a tty
// attached: e.g. Ctrl+C wouldn't copy, but kill the application.
::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
// set the tty layer to pass-through
termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
termdata.c_oflag = 0;
termdata.c_cflag = CREAD | CS8;
termdata.c_lflag = 0;
termdata.c_cc[VTIME]=0;
termdata.c_cc[VMIN]=1;
cfsetispeed(&termdata, 9600);
cfsetospeed(&termdata, 9600);
tcsetattr(m_tty_fd, TCSANOW, &termdata);
To copy to clipboard, switch view to plain text mode
Bookmarks