xref: /original-bsd/lib/libcurses/tstp.c (revision 23a40993)
1 # include	<signal.h>
2 
3 # include	"curses.ext"
4 
5 /*
6  * handle stop and start signals
7  *
8  * 06/25/83 (Berkeley) @(#)tstp.c	1.3
9  */
10 tstp() {
11 
12 # ifdef SIGTSTP
13 
14 	SGTTY	tty;
15 	int	omask;
16 # ifdef DEBUG
17 	if (outf)
18 		fflush(outf);
19 # endif
20 	tty = _tty;
21 	mvcur(0, COLS - 1, LINES - 1, 0);
22 	endwin();
23 	fflush(stdout);
24 	/* reset signal handler so kill below stops us */
25 	signal(SIGTSTP, SIG_DFL);
26 #define	mask(s)	(1 << ((s)-1))
27 	omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP));
28 	kill(0, SIGTSTP);
29 	sigblock(mask(SIGTSTP));
30 	signal(SIGTSTP, tstp);
31 	_tty = tty;
32 	stty(_tty_ch, &_tty);
33 	wrefresh(curscr);
34 # endif	SIGTSTP
35 }
36