Catching ^C and ^Z

R. Kym Horsell vu0310 at bingvaxu.cc.binghamton.edu
Wed Sep 5 22:37:12 AEST 1990


In article <Sep.4.20.08.17.1990.1216 at utopia.rutgers.edu> deen at utopia.rutgers.edu (Cinnamon Raisin) writes:
\\\
>#include <stdio.h>
>#include <sys/ioctl.h>
>#include <sgtty.h>
>char TMP;			/* to hold keyboard entry */
>struct sgttyb *TTY;		/* From unix ref	  */
>
>int main(void)
>{
>  ioctl(0,TIOCGETP,TTY);	/* Get current status	  */
>  TTY->sg_flags = RAW | ECHO;   /* Unprocessed and echoed */
>  ioctl(0,TIOCSETN,TTY);	/* to the screen	  */
>  while(1 == 1) {TMP = getchar();} 
>  exit(0);

A small problem here -- where's the storage for the ioctl buffer?
You have only defined the _pointer_ to that storage area.

What you need is
...
struct sgttyb buffer;
...
ioctl(...,&buffer);
...

And then _maybe_... There are a few conflicting standards
for controlling terminals these days (oh, for the good old
(simple) days of sgtty)! You may want to look up the
``termio'' stuff in your documentation.

-Kym Horsell
======

P.S. Be careful not to lock up your terminal >:-)



More information about the Comp.lang.c mailing list