kernel termios troubles
Hello,
I'm compiling packages for the next Debian release, based on GLIBC 2.1.
I packaged util-linux 2.7.1 but found a bug in the more program.
In effect, I need to hit 4 consecutive keys before the program process the
first. They seem to be buffered, even if the tty is not set to (-icanon).
I'm trying to track down the bug but I don't find it.
I investigated the following parts of my system:
1/ termios vs. termio:
- I replaced any instance of termios by termio, TCGETS by TCGETA and
TCSETSF by TCSETAF in more.c
-> I rebuilt it and now it works.
2/ GLIBC pre2.1 (2.0.91) termios header vs. kernel termios header:
- I replaced the inclusion of GLIBC header (termios.h) in favor of its
kernel counterpart (linux/termios.h). Some minor patches were also made
in more.c to resolve the incompatibility between both header sets.
-> This trial didn't solved my problem.
IMHO it's not a problem in GLIBC.
3/ Old libc 5.3.12 termios:
- I compiled the program on a RedHat 4.2 system with libc5
-> same trouble, not solved.
One part I didn't investigate is the kernel sources. I'm running 2.0.33.
IMO, I think the problem comes from it, but I've not the skills to work on.
I'd appreciate any help.
Thanks in advance.
PS: I extracted the piece of code which fails and compiled it separately.
Here it is:
-------------cut here----------------
/* defined none or one of those symbols to switch between libc termios, libc
termio or kernel termios. */
#undef USE_TERMIO
#undef USE_KERNEL_TERMIOS
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/* based on termio */
#if defined USE_TERMIO
# include <termio.h>
# include <sys/ioctl.h>
/* based on kernel header termios */
#elif defined USE_KERNEL_TERMIOS
# include <linux/termios.h>
# define _TERMIOS_H 1 /* hack to avoid conflict with GLIBC headers */
# define winsize glibc_winsize
# define termio glibc_termio
# include <sys/ioctl.h>
# undef winsize
# undef termio
/* based on GLIBC 2 header termios */
#else
# include <termios.h>
# include <sys/ioctl.h>
#endif
#ifdef USE_TERMIO
# define set_tty(fd,argp) ioctl(fd,TCSETAF,argp)
# define get_tty(fd,argp) ioctl(fd,TCGETA,argp)
struct termio otty, savetty;
#else
# define set_tty(fd,argp) ioctl(fd,TCSETSF,argp)
# define get_tty(fd,argp) ioctl(fd,TCGETS,argp)
struct termios otty, savetty;
#endif
int main(int argc, char **argv) {
char input[2] = "";
get_tty( fileno(stdin), &otty ); /* save tty state */
savetty = otty;
otty.c_lflag &= ~(ICANON|ECHO); /* unbuffered, no echo */
set_tty( fileno(stdin), &otty );
write( fileno(stdout), "input: ", 7 );
read( fileno(stdin), &input, 1 ); /* wait for a key to hit */
set_tty( fileno(stdin), &savetty ); /* restore old state */
printf( "--> %s\n", input );
}
-------------cut here----------------
--
Eric Delaunay | "La guerre justifie l'existence des militaires.
delaunay@lix.polytechnique.fr | En les supprimant." Henri Jeanson (1900-1970)
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-sparc-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: