xref: /csrg-svn/lib/libcurses/tstp.c (revision 42657)
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.5 (Berkeley) 06/01/90";
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.5 (Berkeley) 06/01/90
20  */
21 tstp() {
22 
23 # ifdef SIGTSTP
24 
25 	SGTTY	tty;
26 	int	omask;
27 # ifdef DEBUG
28 	if (outf)
29 		fflush(outf);
30 # endif
31 	tty = _tty;
32 	mvcur(0, COLS - 1, LINES - 1, 0);
33 	endwin();
34 	fflush(stdout);
35 	/* reset signal handler so kill below stops us */
36 	signal(SIGTSTP, SIG_DFL);
37 #define	mask(s)	(1 << ((s)-1))
38 	omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP));
39 	kill(0, SIGTSTP);
40 	sigblock(mask(SIGTSTP));
41 	signal(SIGTSTP, tstp);
42 	_tty = tty;
43 	ioctl(_tty_ch, TIOCSETP, &_tty);
44 	wrefresh(curscr);
45 # endif	SIGTSTP
46 }
47