Re: on key (CONTROL-O)
Posted in 1995
In article <4bfksm$9u3@news.informix.com> aland@informix.com (Colonel Panic) writes: From: aland@informix.com (Colonel Panic) Newsgroups: comp.databases.informix Date: 23 Dec 1995 01:09:42 GMT In article <4bcn1k$kc1@cssun.mathcs.emory.edu>, Sanjay Kumar <SOHO!dpsanjay@whitestone.raileurope.com> wrote: >We faced the same problem. We had to change to some other key. I had >called Informix Tech support ; I was told it was a bug. Probably not. It was originally logged as bug 31925, but it now appears that the real problem was that CONTROL-O was defined in stty as having a special meaning. Therefore, no application would see a ^O character when ^O was struck -- the tty interface intercepted the keystroke instead. (For example, on a Solaris "sun" window, ^O is the "flush" key. If I undefine the flush key, ^O works as expected.) Moral: check the output of stty -a (or equivalent) to ensure that the tty interface doesn't convert the control character into a signal or somesuch. I made follow sub-routin for the case of ^O character set another meaning in stty, commpare with "Advancedd Programing in the UNIX Environment" by W.Richard Stevens. ------- Cut here ----------------------------------------------------------- #include <termios.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> extern _debug; void err_sys(); void err_quit(); struct termios sv_term; int save_term(n) int n; { if (tcgetattr(STDIN_FILENO, &sv_term) < 0) /* fetch tty state */ err_sys("tcgetatttr error"); retint(&sv_term); return(1); } int restore_term(n) int n; { int term_ptr; struct termios *wk_term; popint(&term_ptr); wk_term = (struct termios *)term_ptr; if (tcsetattr(STDIN_FILENO,TCSAFLUSH, wk_term) < 0) err_sys("tcsetattr error"); return(1); } int disable_sc(n) int n; { int chno; struct termios term; lon vdisable; int i; popint(&chno); if (isatty(STDIN_FILENO) == 0) err_quit("standard input is not a terminal device"); if ( (vdisable = fpathconf(STDIN_FILENO, _PC_VDISABLE)) < 0) err_quit("fpathconf error or _POSIZ_VDISABLE not in effect"); if (tcgetattr(STDIN_FILENO, &term) < 0) /* fetch tty state */ err_sys("tcgetatttr error"); for (i = 0; i < NCCS; i++) { if (term.c_cc[i] == chno){ term.c_cc[i] = vdisable; /* disable */ if (_debug) { printf("chno %d used for %d\\n", chno,i); } } } if (tcsetattr(STDIN_FILENO,TCSAFLUSH, &term) < 0) err_sys("tcsetattr error"); retint(0); return(1); } void err_quit(str) char *str; { perror(str); exit(1); } void err_sys(str) char *str; { perror(str); } ---------------------------------------------------------------------------- follow is how to use in 4gl MAIN DEFINE dstat INTEGER, key_val INTEGER, sv_term INTEGER CALL save_term() RETURNING sv_term LET key_val = fgl_keyval("control-o") { or other key } CALL disable_sc(key_val) RETURNING dstat { key_val .. perhaps 15 } : : do your job : CALL restore_term(sv_term) RETURNING dstat END MAIN -- SEKIMOT Shouichi Email: sekimoto@sra.co.jp