Xref: utzoo comp.lang.c:31593 comp.unix.questions:25238 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!seismo!dimacs.rutgers.edu!aramis.rutgers.edu!remus.rutgers.edu!utopia.rutgers.edu!deen From: deen@utopia.rutgers.edu (Cinnamon Raisin) Newsgroups: comp.lang.c,comp.unix.questions Subject: Catching ^C and ^Z Message-ID: Date: 5 Sep 90 00:08:20 GMT Followup-To: comp.lang.c Organization: The Diamond Z Lines: 52 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 #include #include 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@police.rutgers.edu