Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!swrinde!ucsd!hub.ucsb.edu!spectrum.CMC.COM!lars From: lars@spectrum.CMC.COM (Lars Poulsen) Newsgroups: comp.lang.c Subject: Re: Catching ^C and ^Z Message-ID: <1990Sep6.183549.28024@spectrum.CMC.COM> Date: 6 Sep 90 18:35:49 GMT References: Organization: Rockwell CMC Lines: 34 In article deen@utopia.rutgers.edu (Cinnamon Raisin) writes: > 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); >} The ioctl() functions move data between internal places in the system and a structure of type "struct sgttyb" in your program. You have created a variable to hold a pointer to such a structure, but you have never created a structure to actually hold the data, and your pointer has never been initialized. The following changes should cure the problem: struct sgttyb TTY; ioctl(0,TIOCGETP,&TTY); /* Get current status */ -- / Lars Poulsen, SMTS Software Engineer CMC Rockwell lars@CMC.COM