mirror of
https://abf.rosa.ru/djam/glibc.git
synced 2025-02-23 15:02:47 +00:00
47 lines
1.5 KiB
Diff
47 lines
1.5 KiB
Diff
--- glibc-2.3.2/sysdeps/unix/sysv/linux/tcsetattr.c.tcsetattr-kernel-bug-workaround 2003-02-24 21:26:01.000000000 +0100
|
|
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/tcsetattr.c 2003-06-05 11:11:01.000000000 +0200
|
|
@@ -56,6 +56,7 @@ tcsetattr (fd, optional_actions, termios
|
|
{
|
|
struct __kernel_termios k_termios;
|
|
unsigned long int cmd;
|
|
+ int retval;
|
|
|
|
switch (optional_actions)
|
|
{
|
|
@@ -87,6 +88,35 @@ tcsetattr (fd, optional_actions, termios
|
|
memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
|
|
__KERNEL_NCCS * sizeof (cc_t));
|
|
|
|
- return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
|
|
+ retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
|
|
+
|
|
+ if (retval == 0 && cmd == TCSETS)
|
|
+ {
|
|
+ /* The Linux kernel has a bug which silently ignore the invalid
|
|
+ c_cflag on pty. We have to check it here. */
|
|
+ int save = errno;
|
|
+ retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios);
|
|
+ if (retval)
|
|
+ {
|
|
+ /* We cannot verify if the setting is ok. We don't return
|
|
+ an error (?). */
|
|
+ __set_errno (save);
|
|
+ retval = 0;
|
|
+ }
|
|
+ else if ((termios_p->c_cflag & (PARENB | CREAD))
|
|
+ != (k_termios.c_cflag & (PARENB | CREAD))
|
|
+ || ((termios_p->c_cflag & CSIZE)
|
|
+ && ((termios_p->c_cflag & CSIZE)
|
|
+ != (k_termios.c_cflag & CSIZE))))
|
|
+ {
|
|
+ /* It looks like the Linux kernel silently changed the
|
|
+ PARENB/CREAD/CSIZE bits in c_cflag. Report it as an
|
|
+ error. */
|
|
+ __set_errno (EINVAL);
|
|
+ retval = -1;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return retval;
|
|
}
|
|
libc_hidden_def (tcsetattr)
|