Catching ^C and ^Z
Cinnamon Raisin
deen at utopia.rutgers.edu
Wed Sep 5 10:08:20 AEST 1990
Hi boys and girls,
I am trying to write a quick programme to lock a terminal(TTY)
when I leave it. Essentially I want to capture all the
interrupts that can be sent from the keyboard, such as
SIG_INT,SIG_QUIT and so on. The only reasonable thing I've
found that lets me do this is ioctl().
Essentially I need to get all the characters from the keyboard
in the RAW mode, sos I can process them myself. How can I do
this. The unix ref is a bit hazy on the topic and the mann page
makes no mention of the RAW mode.
I know I need to capture the current mode,
push my mode onto the system
deal with the passwords and junk from keyboard
and restore the captured mode.
The following is a short programme I wrote to test this out,
but it dumps on me, and I don't know why.
------------
#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);
}
------------
Do I have the calling parameters typed wrongly or somethin?
...Tanx in Advanz...
-Z Raisin
--
---
"May The Prezent Tenz Be With You."
-The Super Amazin Cinnamon Raisin
deen at police.rutgers.edu
More information about the Comp.unix.questions
mailing list