Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7c4193

Browse files
committed
In tcsetattr(), first initialize the mode structure by calling
tcgetattr(). This seems to be the only correct way to cope with platform-specific structure members...
1 parent ae9ee73 commit e7c4193

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Modules/termios.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ termios_tcsetattr(self, args)
139139
return NULL;
140140
}
141141

142+
/* Get the old mode, in case there are any hidden fields... */
143+
if (tcgetattr(fd, &mode) == -1)
144+
return PyErr_SetFromErrno(TermiosError);
142145
mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0));
143146
mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1));
144147
mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2));

0 commit comments

Comments
 (0)