1 diff -Nrup a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c
2 --- a/sysdeps/unix/sysv/linux/tcsetattr.c 2012-06-05 07:42:49.000000000 -0600
3 +++ b/sysdeps/unix/sysv/linux/tcsetattr.c 2012-06-07 12:15:21.831318623 -0600
4 @@ -48,6 +48,7 @@ tcsetattr (fd, optional_actions, termios
6 struct __kernel_termios k_termios;
10 switch (optional_actions)
12 @@ -79,6 +80,35 @@ tcsetattr (fd, optional_actions, termios
13 memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
14 __KERNEL_NCCS * sizeof (cc_t));
16 - return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
17 + retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
19 + if (retval == 0 && cmd == TCSETS)
21 + /* The Linux kernel has a bug which silently ignore the invalid
22 + c_cflag on pty. We have to check it here. */
24 + retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios);
27 + /* We cannot verify if the setting is ok. We don't return
32 + else if ((termios_p->c_cflag & (PARENB | CREAD))
33 + != (k_termios.c_cflag & (PARENB | CREAD))
34 + || ((termios_p->c_cflag & CSIZE)
35 + && ((termios_p->c_cflag & CSIZE)
36 + != (k_termios.c_cflag & CSIZE))))
38 + /* It looks like the Linux kernel silently changed the
39 + PARENB/CREAD/CSIZE bits in c_cflag. Report it as an
41 + __set_errno (EINVAL);
48 libc_hidden_def (tcsetattr)