void vl_save_tty(void) { ioctl(0, TCGETA, (char *) &otermio); /* save old settings */ intrc = otermio.c_cc[VINTR]; killc = otermio.c_cc[VKILL]; startc = tocntrl('Q'); stopc = tocntrl('S'); backspc = otermio.c_cc[VERASE]; wkillc = tocntrl('W'); #if SIGTSTP #ifdef V_SUSP suspc = otermio.c_cc[V_SUSP]; #else suspc = -1; #endif #else /* no SIGTSTP */ suspc = tocntrl('Z'); #endif saved_tty = TRUE; }
void vl_save_tty(void) { int s; s = tcgetattr(0, &otermios); if (s < 0) { perror("vl_save_tty tcgetattr"); ExitProgram(BADEXIT); } suspc = otermios.c_cc[VSUSP]; intrc = otermios.c_cc[VINTR]; killc = otermios.c_cc[VKILL]; startc = otermios.c_cc[VSTART]; stopc = otermios.c_cc[VSTOP]; backspc = otermios.c_cc[VERASE]; #ifdef VWERASE /* Sun has it. any others? */ wkillc = otermios.c_cc[VWERASE]; #else wkillc = tocntrl('W'); #endif saved_tty = TRUE; }
void ttopen() { int s; s = tcgetattr(0, &otermios); if (s < 0) { perror("ttopen tcgetattr"); ExitProgram(BAD(1)); } /* the "|| USG" below is to support SVR4 -- let me know if it conflicts on other systems */ #if ODT || ISC || USG setvbuf(stdout, tobuf, _IOLBF, TBUFSIZ); #else setbuffer(stdout, tobuf, TBUFSIZ); #endif suspc = otermios.c_cc[VSUSP]; intrc = otermios.c_cc[VINTR]; killc = otermios.c_cc[VKILL]; startc = otermios.c_cc[VSTART]; stopc = otermios.c_cc[VSTOP]; backspc = otermios.c_cc[VERASE]; #ifdef VWERASE /* Sun has it. any others? */ wkillc = otermios.c_cc[VWERASE]; #else wkillc = tocntrl('W'); #endif /* this could probably be done more POSIX'ish? */ (void)signal(SIGTSTP,SIG_DFL); /* set signals so that we can */ (void)signal(SIGCONT,rtfrmshell); /* suspend & restart */ (void)signal(SIGTTOU,SIG_IGN); /* ignore output prevention */ #if USE_FCNTL kbd_flags = fcntl( 0, F_GETFL, 0 ); kbd_is_polled = FALSE; #endif #if ! X11 ntermios = otermios; /* setup new settings, preserve flow control, and allow BREAK */ ntermios.c_iflag = BRKINT|(otermios.c_iflag & (IXON|IXANY|IXOFF)); ntermios.c_oflag = 0; ntermios.c_lflag = ISIG; ntermios.c_cc[VMIN] = 1; ntermios.c_cc[VTIME] = 0; #ifdef VSWTCH ntermios.c_cc[VSWTCH] = -1; #endif ntermios.c_cc[VSUSP] = -1; ntermios.c_cc[VSTART] = -1; ntermios.c_cc[VSTOP] = -1; #endif ttmiscinit(); ttunclean(); }