Это линукс-то долбаный, после того, какая содомия в маздае
творится? А флаги надо обнулять, если нет желания каждый ненужный отдельно коверкать.
Вот, например.
struct termios2 newtty;
if(ioctl(comfd, TCGETS2, &newtty)){ // Get settings
WARN(_("Can't get old TTY settings"));
return -1;
}
newtty.c_lflag = 0; // ~(ICANON | ECHO | ECHOE | ISIG)
newtty.c_iflag = 0; // don't do any changes in input stream
newtty.c_oflag = 0; // don't do any changes in output stream
newtty.c_cflag = BOTHER | flags | CREAD | CLOCAL; // other speed, user format, RW, ignore line ctrl
newtty.c_ispeed = speed;
newtty.c_ospeed = speed;
newtty.c_cc[VMIN] = 0; // non-canonical mode
newtty.c_cc[VTIME] = 1;
if(ioctl(comfd, TCSETS2, &newtty)){
WARN(_("Can't apply new TTY settings"));
close(comfd);
return -1;
}