This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Problem in sysdeps/unix/sysv/linux/tcsetattr.c
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Mon, 17 Feb 2003 17:38:36 +0100
- Subject: Problem in sysdeps/unix/sysv/linux/tcsetattr.c
Hi,
in this file we have:
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 = __ioctl (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;
}
}
How is this "error checking" supposed to work against PTYs with this in the
kernel (2.5.61 drivers/char/pty.c):
static void pty_set_termios(struct tty_struct *tty, struct termios
*old_termios)
{
tty->termios->c_cflag &= ~(CSIZE | PARENB);
tty->termios->c_cflag |= (CS8 | CREAD);
}
This lets 7bit xterm fail with:
[fsirl@enzo:~]$ xterm
xterm: fatal pty error 23 (errno=22) on tty /dev/pts/11
Was the above error check possibly be obsoleted by newer kernel versions? Then
we could handle that with an __ASSUME_WORKING_TCSETS.
Franz.