void tty_init(void) { /* ATT terminal init */ #if defined(F_GETFL) && defined(O_NDELAY) int flags; flags = fcntl(fileno(stdin), F_GETFL, 0); nodelay_read = flags & O_NDELAY; #else nodelay_read = FALSE; #endif not_a_tty = FALSE; if (GET_TTY(fileno(stdin), &old_modes) == -1) { if (errno == ENOTTY) { tty_frame_size = 20; not_a_tty = TRUE; return; } printf("tcgetattr error: %d\n", errno); exit(1); } /* if TAB3 is set then setterm() wipes out tabs (ht) */ new_modes = old_modes; #ifdef TERMIOS #ifdef TABDLY new_modes.c_oflag &= ~TABDLY; #endif /* TABDLY */ #endif if (PUT_TTY(fileno(stdin), &new_modes) == -1) { printf("tcsetattr error: %d\n", errno); exit(1); } #ifdef sequent /* the sequent ATT emulation is broken soooo. */ old_modes.c_cflag &= ~(CSIZE | CSTOPB); old_modes.c_cflag |= CS7 | PARENB; #endif catchsig(); #ifdef TERMIOS switch (old_modes.c_cflag & CSIZE) { #if defined(CS5) && (CS5 != 0) case CS5: tty_frame_size = 10; break; #endif #if defined(CS6) && (CS6 != 0) case CS6: tty_frame_size = 12; break; #endif #if defined(CS7) && (CS7 != 0) case CS7: tty_frame_size = 14; break; #endif #if defined(CS8) && (CS8 != 0) case CS8: tty_frame_size = 16; break; #endif } tty_frame_size += 2 + ((old_modes.c_cflag & PARENB) ? 2 : 0) + ((old_modes.c_cflag & CSTOPB) ? 4 : 2); #else tty_frame_size = 6 + (old_modes.sg_flags & PASS8) ? 16 : 14; #endif }
static void on_external_ui_closed(void* controller) { catchsig(0); }
static void InitSig( void ) { catchsig( SIGHUP, signal_handler ); catchsig( SIGQUIT, signal_handler ); catchsig( SIGILL, signal_handler ); catchsig( SIGTRAP, signal_handler ); catchsig( SIGIOT, signal_handler ); catchsig( SIGBUS, signal_handler ); catchsig( SIGFPE, signal_handler ); catchsig( SIGSEGV, signal_handler ); catchsig( SIGTERM, signal_handler ); catchsig( SIGINT, signal_handler ); catchsig( SIGPIPE, SIG_IGN ); catchsig( SIGUSR1, sigusr_handler ); }