mcooper@usc-oberon.UUCP (Michael A. Cooper) (07/11/86)
I'm trying to figure out how to set some tty modes under System V.2 (on a 3B20S) for a particulair application I have. Since I'm a Berkeley UNIX person, I have almost no System V background. Anyway, I'm using the following macros to accomplish my task: #define crmode() (_tty.c_lflag &=~ICANON, _tty.c_cc[VMIN] = 1,\ _tty.c_cc[VTIME] = 1,\ ioctl(_tty_ch,TCSETAF,&_tty)) #define nocrmode() (_tty.c_lflag |= ICANON, stty(_tty_ch,&_tty)) #define echo() (_tty.c_lflag |= ECHO, ioctl(_tty_ch, TCSETA, &_tty)) #define noecho() (_tty.c_lflag &=~ECHO, ioctl(_tty_ch, TCSETA, &_tty)) The problem is that when I use the macros, I get logged out. I assume because my tty "speed" is set to 0 (hangup). Would someone care to "enlighten" me to the System V idiosincroties of tty modes? -- Michael Cooper, U of Southern California Computing Services, (213) 743-3462 UUCP: {sdcrdcf, uscvax}!usc-oberon!mcooper ARPA: mcooper@usc-oberon.arpa BITNET: mcooper@uscvaxq
rcodi@goanna.UUCP (07/18/86)
> #define crmode() (_tty.c_lflag &=~ICANON, _tty.c_cc[VMIN] = 1,\ > _tty.c_cc[VTIME] = 1,\ > ioctl(_tty_ch,TCSETAF,&_tty)) > The problem is that when I use the macros, I get logged out. I assume > because my tty "speed" is set to 0 (hangup). I suppose this is a silly question, but did you ioctl(_tty_ch, TCGETA, &_tty) before you used these macros? If you didn't, then the _tty structure would be all zeros if it is static, or all garbage if it is stack resident. You should also save VMIN and VTIME values in crmode(), and restore them in nocrmode() as they overlay EOF and EOL in the termio structure. If you don't, then your EOF and EOL characters will be incorrect in nocrmode(). It might be better to write routines rather than macros to do this properly. Ian Donaldson