xref: /original-bsd/lib/libcurses/tstp.c (revision e59fb703)
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.6 (Berkeley) 03/03/91";
10 #endif /* not lint */
11 
12 # include	<signal.h>
13 
14 # include	"curses.ext"
15 
16 /*
17  * handle stop and start signals
18  *
19  * @(#)tstp.c	5.6 (Berkeley) 03/03/91
20  */
21 void
22 tstp() {
23 
24 # ifdef SIGTSTP
25 
26 	SGTTY	tty;
27 	int	omask;
28 # ifdef DEBUG
29 	if (outf)
30 		fflush(outf);
31 # endif
32 	tty = _tty;
33 	mvcur(0, COLS - 1, LINES - 1, 0);
34 	endwin();
35 	fflush(stdout);
36 	/* reset signal handler so kill below stops us */
37 	signal(SIGTSTP, SIG_DFL);
38 #define	mask(s)	(1 << ((s)-1))
39 	omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP));
40 	kill(0, SIGTSTP);
41 	sigblock(mask(SIGTSTP));
42 	signal(SIGTSTP, tstp);
43 	_tty = tty;
44 	ioctl(_tty_ch, TIOCSETP, &_tty);
45 	wrefresh(curscr);
46 # endif	SIGTSTP
47 }
48