xref: /titanic_50/usr/src/ucblib/libcurses/tstp.c (revision 24da5b34f49324ed742a340010ed5bd3d4e06625)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 #ifndef lint
18 static char
19 sccsid[] = "@(#)tstp.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
20 #endif /* not lint */
21 
22 #include	<sys/types.h>
23 #include	<signal.h>
24 #include	"curses.ext"
25 #include	<sgtty.h>
26 
27 /*
28  * handle stop and start signals
29  *
30  * @(#)tstp.c	5.1 (Berkeley) 6/7/85
31  */
32 
33 void
34 tstp(void)
35 {
36 #ifdef SIGTSTP
37 
38 	SGTTY	tty;
39 #ifdef DEBUG
40 	if (outf)
41 		(void) fflush(outf);
42 #endif
43 	tty = _tty;
44 	(void) mvcur(0, COLS - 1, LINES - 1, 0);
45 	(void) endwin();
46 	(void) fflush(stdout);
47 	/* reset signal handler so kill below stops us */
48 	(void) signal(SIGTSTP, SIG_DFL);
49 	(void) sigsetmask(sigblock(0) &~ sigmask(SIGTSTP));
50 	(void) kill(0, SIGTSTP);
51 	(void) sigblock(sigmask(SIGTSTP));
52 	(void) signal(SIGTSTP, (void(*)(int))tstp);
53 	_tty = tty;
54 	(void) stty(_tty_ch, &_tty);
55 	(void) wrefresh(curscr);
56 #endif	/* SIGTSTP */
57 }
58