void tty_init() { extern struct tty_state tty; /* global var */ struct sigaction sigact; struct vt_mode vtm; char *env; memset(&sigact, 0, sizeof(struct sigaction)); sigact.sa_handler = handler; sigact.sa_flags = SA_RESTART; esigaction(SIGCHLD, &sigact, NULL); esigaction(SIGUSR1, &sigact, NULL); vtm.mode = VT_PROCESS; vtm.waitv = 0; vtm.relsig = vtm.acqsig = vtm.frsig = SIGUSR1; if (ioctl(STDIN_FILENO, VT_SETMODE, &vtm)) fatal("ioctl: VT_SETMODE failed (maybe here is not console)"); if (ioctl(STDIN_FILENO, KDSETMODE, KD_GRAPHICS) < 0) fatal("ioctl: KDSETMODE failed (maybe here is not console)"); tty.save_tm = (struct termios *) emalloc(sizeof(struct termios)); set_rawmode(STDIN_FILENO, tty.save_tm); ewrite(STDIN_FILENO, "\033[?25l", 6); /* make cusor invisible */ if ((env = getenv("YAFT")) != NULL) { if (strstr(env, "background") != NULL) tty.background_draw = true; if (strstr(env, "lazy") != NULL) tty.lazy_draw = true; } }
void tty_init() { struct sigaction sigact; memset(&sigact, 0, sizeof(struct sigaction)); sigact.sa_handler = handler; sigact.sa_flags = SA_RESTART; esigaction(SIGCHLD, &sigact, NULL); }
int set_signal(int signo, void (*sig_handler)(int signo)) { struct sigaction sigact; memset(&sigact, 0, sizeof(struct sigaction)); sigact.sa_handler = sig_handler; sigact.sa_flags = SA_RESTART; return esigaction(signo, &sigact, NULL); }