Home | History | Annotate | Line # | Download | only in hack
hack.ioctl.c revision 1.1
      1  1.1  cgd /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
      2  1.1  cgd /* hack.ioctl.c - version 1.0.2 */
      3  1.1  cgd 
      4  1.1  cgd /* This cannot be part of hack.tty.c (as it was earlier) since on some
      5  1.1  cgd    systems (e.g. MUNIX) the include files <termio.h> and <sgtty.h>
      6  1.1  cgd    define the same constants, and the C preprocessor complains. */
      7  1.1  cgd #include <stdio.h>
      8  1.1  cgd #include "config.h"
      9  1.1  cgd #ifdef BSD
     10  1.1  cgd #include	<sgtty.h>
     11  1.1  cgd struct ltchars ltchars, ltchars0;
     12  1.1  cgd #else
     13  1.1  cgd #include	<termio.h>	/* also includes part of <sgtty.h> */
     14  1.1  cgd struct termio termio;
     15  1.1  cgd #endif BSD
     16  1.1  cgd 
     17  1.1  cgd getioctls() {
     18  1.1  cgd #ifdef BSD
     19  1.1  cgd 	(void) ioctl(fileno(stdin), (int) TIOCGLTC, (char *) &ltchars);
     20  1.1  cgd 	(void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) &ltchars0);
     21  1.1  cgd #else
     22  1.1  cgd 	(void) ioctl(fileno(stdin), (int) TCGETA, &termio);
     23  1.1  cgd #endif BSD
     24  1.1  cgd }
     25  1.1  cgd 
     26  1.1  cgd setioctls() {
     27  1.1  cgd #ifdef BSD
     28  1.1  cgd 	(void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) &ltchars);
     29  1.1  cgd #else
     30  1.1  cgd 	(void) ioctl(fileno(stdin), (int) TCSETA, &termio);
     31  1.1  cgd #endif BSD
     32  1.1  cgd }
     33  1.1  cgd 
     34  1.1  cgd #ifdef SUSPEND		/* implies BSD */
     35  1.1  cgd dosuspend() {
     36  1.1  cgd #include	<signal.h>
     37  1.1  cgd #ifdef SIGTSTP
     38  1.1  cgd 	if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
     39  1.1  cgd 		settty((char *) 0);
     40  1.1  cgd 		(void) signal(SIGTSTP, SIG_DFL);
     41  1.1  cgd 		(void) kill(0, SIGTSTP);
     42  1.1  cgd 		gettty();
     43  1.1  cgd 		setftty();
     44  1.1  cgd 		docrt();
     45  1.1  cgd 	} else {
     46  1.1  cgd 		pline("I don't think your shell has job control.");
     47  1.1  cgd 	}
     48  1.1  cgd #else SIGTSTP
     49  1.1  cgd 	pline("Sorry, it seems we have no SIGTSTP here. Try ! or S.");
     50  1.1  cgd #endif SIGTSTP
     51  1.1  cgd 	return(0);
     52  1.1  cgd }
     53  1.1  cgd #endif SUSPEND
     54