1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)tstp.c 5.7 (Berkeley) 08/23/92"; 10 #endif /* not lint */ 11 12 #include <curses.h> 13 #include <errno.h> 14 #include <signal.h> 15 #include <termios.h> 16 #include <unistd.h> 17 18 /* 19 * tstp -- 20 * Handle stop and start signals. 21 */ 22 void 23 tstp(signo) 24 int signo; 25 { 26 struct termios save; 27 sigset_t set; 28 29 /* Get the current terminal state. */ 30 if (tcgetattr(STDIN_FILENO, &save)) 31 return; 32 33 /* Move the cursor to the end of the screen. */ 34 mvcur(0, COLS - 1, LINES - 1, 0); 35 36 /* End the window. */ 37 endwin(); 38 39 /* Stop ourselves. */ 40 (void)sigemptyset(&set); 41 (void)sigaddset(&set, SIGTSTP); 42 (void)sigprocmask(SIG_UNBLOCK, &set, NULL); 43 (void)signal(SIGTSTP, SIG_DFL); 44 (void)kill(0, SIGTSTP); 45 46 /* Time passes ... */ 47 48 /* Reset the signal handler. */ 49 (void)signal(SIGTSTP, tstp); 50 51 /* Reset the terminal state. */ 52 (void)tcsetattr(STDIN_FILENO, TCSADRAIN, &save); 53 54 /* Restart the screen. */ 55 wrefresh(curscr); 56 } 57