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