From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 20880 invoked from network); 5 Mar 1998 11:35:05 -0000 Received: from c56-rizzo.blarg.net (HELO toshi.naka.net) (206.124.131.57) by mail2.redhat.com with SMTP; 5 Mar 1998 11:35:05 -0000 Received: from localhost (wknaka@localhost) by toshi.naka.net (8.7.5/8.7.3) with SMTP id DAA00707 for ; Thu, 5 Mar 1998 03:32:18 -0800 X-Authentication-Warning: toshi.naka.net: wknaka owned process doing -bs Date: Thu, 5 Mar 1998 03:32:11 -0800 (PST) From: Wes Nakamura Sender: wknaka@toshi To: axp-list@redhat.com Subject: text editor/fcntl/ioctl Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi, I'm trying to compile a text editor under linux/alpha. It compiles and links fine but doesn't quite work. The problem is that it takes 4 keystrokes before anything happens. If I type "1234" nothing happens until the "4" has been typed, then all 4 characters appear at once. The 3 characters you type after the first aren't lost, they just aren't handled until the last is typed. After that it requires another 4 keystrokes before they're handled. At first I thought it was a screen update problem, but it appears not to be. I've cut out some code to simplify the problem (see below). I don't really understand what's going on in the init function other than some io device manipulation. I've also tried running this under intel linux (the editor runs fine with no modifications under intel linux). This sample code exits after one keystroke on intel whereas the alpha one requires 4. This is with a basically clean redhat 5.0 install, 2.0.33 kernel. Thanks to anyone who can shed some light on this. -Wes. ---------- #include #include #include #include struct termio gt; void dont_panic(char* s) { printf("%s: don't panic!\n", s); exit(-1); } void init(void) { static struct termio ot; static struct termio nt; if (ioctl(0, TCGETA, &ot) < 0) dont_panic("ioctl0"); gt = ot; nt = ot; /* save entry state */ nt.c_cc[VMIN] = 1; /* one character read is OK */ nt.c_cc[VTIME] = 0; /* Never time out. */ nt.c_iflag |= IGNBRK; nt.c_iflag &= ~( ICRNL | INLCR | ISTRIP | IXON | IXOFF ); nt.c_oflag &= ~OPOST; nt.c_cflag |= CS8; /* allow 8th bit on input */ nt.c_cflag &= ~PARENB; /* Don't check parity */ nt.c_lflag &= ~( ECHO | ICANON | ISIG ); if (ioctl(0, TCSETAF, &nt) < 0) dont_panic("ioctl1"); } int main(void) { int i; char c; init(); if (fcntl(0, F_SETFL, O_APPEND) < 0) dont_panic("fnctl"); i = read(0, &c, 1); if (i < 0) dont_panic("read"); printf("%c\n", c); if (ioctl(0, TCSETAF, >) < 0) dont_panic("ioctl2"); return 0; } -EOF-