xref: /illumos-gate/usr/src/ucblib/libcurses/tstp.c (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
1 /*
2  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved.  The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #ifndef lint
16 static char
17 sccsid[] = "@(#)tstp.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
18 #endif /* not lint */
19 
20 #include	<sys/types.h>
21 #include	<signal.h>
22 #include	"curses.ext"
23 #include	<sgtty.h>
24 
25 /*
26  * handle stop and start signals
27  *
28  * @(#)tstp.c	5.1 (Berkeley) 6/7/85
29  */
30 
31 void
32 tstp(void)
33 {
34 #ifdef SIGTSTP
35 
36 	SGTTY	tty;
37 #ifdef DEBUG
38 	if (outf)
39 		(void) fflush(outf);
40 #endif
41 	tty = _tty;
42 	(void) mvcur(0, COLS - 1, LINES - 1, 0);
43 	(void) endwin();
44 	(void) fflush(stdout);
45 	/* reset signal handler so kill below stops us */
46 	(void) signal(SIGTSTP, SIG_DFL);
47 	(void) sigsetmask(sigblock(0) &~ sigmask(SIGTSTP));
48 	(void) kill(0, SIGTSTP);
49 	(void) sigblock(sigmask(SIGTSTP));
50 	(void) signal(SIGTSTP, (void(*)(int))tstp);
51 	_tty = tty;
52 	(void) stty(_tty_ch, &_tty);
53 	(void) wrefresh(curscr);
54 #endif	/* SIGTSTP */
55 }
56