Catching ^C and ^Z

Fred Gansevles gansevle at cs.utwente.nl
Fri Sep 7 16:47:16 AEST 1990


In article <Sep.4.20.08.17.1990.1216 at utopia.rutgers.edu>,
deen at utopia.rutgers.edu (Cinnamon Raisin) writes:
|>
|>Hi boys and girls,
|>
|>	I am trying to write a quick programme to lock a terminal(TTY)
|>	[ stuff deleted ]
|>
|>------------
|>
|>#include <stdio.h>
|>#include <sys/ioctl.h>
|>#include <sgtty.h>
|>char TMP;			/* to hold keyboard entry */
|>struct sgttyb *TTY;		/* From unix ref	  */
  struct sgttyb TTY;
|>
|>int main(void)
|>{
|>  ioctl(0,TIOCGETP,TTY);	/* Get current status	  */
    ioctl(0,TIOCGETP,&TTY);     /* ioctl fills the pointer you pass */
|>  TTY->sg_flags = RAW | ECHO;   /* Unprocessed and echoed */
    TTY.sg_flags = RAW | ECHO;
|>  ioctl(0,TIOCSETN,TTY);	/* to the screen	  */
    ioctl(0,TIOCSETN,&TTY) 
|>  while(1 == 1) {TMP = getchar();} 
|>  exit(0);
|>}
|>
|>------------
|>
|>	Do I have the calling parameters typed wrongly or somethin?
                                               ^^^^^^^ YES.

This should do the trick.

Fred.         
________________________________________________________________________

Fred Gansevles              gansevle at cs.utwente.nl        

INF Laboratory
University Twente
Enschede
The Netherlands
_________________________________________________________________________



More information about the Comp.lang.c mailing list