sabi@vax1.acs.udel.EDU (Sabita Nagarajan) (08/09/90)
I have an application which sends large amounts of output to the terminal. I'd like to be able to stop the output by pressing one key. To do this, I have been doing something like this: close(0); if(open("/dev/tty", O_RDWR | O_NDELAY) == -1) { fprintf(stderr, open_error_message); exit(1); } ... if(ioctl(0, TCGETA, &tsave) == -1) { fprintf(stderr, ioctl_error_message); exit(1); } tchange = tsave; tchange.c_lflag &= ~(ICANON | ECHO); tchange.c_cc[VMIN] = 1; tchange.c_cc[VTIME] = 0; if(ioctl(0, TCSETAF, &tchange) == -1) { fprintf(stderr, ioctl_error_message); exit(1); } ... And then to do the read: while(TRUE) { output_to_terminal(); c = '\0'; read(0, &c, 1); if(c != '\0') exit(); } Well, not exactly, but you get the idea. This is a fairly straightforward polling scheme, but I notice there's still some slight delay between the time I press the key and the program exit. This is especially true on terminals I have hooked up to standard serial ports (Oops, sorry, I have a Wyse 3225 running SCO Xenix 2.3.2 and Computone 16 port board). I'm running off the standard ports because it looks like whenever I put the Computone ports into raw mode, a SIGHUP is generated somehow. But that's another question. My question here is: How can I get a faster response from the keyboard? The output_to_terminal only has to put out a couple of chars at a time before returning, so it's pretty fast. What can I do to speed things up? Thanks in advance!! looking for a way to gener