From: Guido van Rossum Date: Fri, 12 Jun 1998 14:26:18 +0000 (+0000) Subject: In tcsetattr(), first initialize the mode structure by calling X-Git-Tag: v1.5.2a1~479 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e7c4193755843e308df180f3014cea214fbf6dc5;p=thirdparty%2FPython%2Fcpython.git 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... --- diff --git a/Modules/termios.c b/Modules/termios.c index 55295a8e45e1..d7afeaec6853 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -139,6 +139,9 @@ termios_tcsetattr(self, args) return NULL; } + /* Get the old mode, in case there are any hidden fields... */ + if (tcgetattr(fd, &mode) == -1) + return PyErr_SetFromErrno(TermiosError); mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0)); mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1)); mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2));