Date: Thu, 25 Jun 1998 16:45:55 +0300 (IDT) From: Eli Zaretskii To: Carsten Svaneborg cc: djgpp AT delorie DOT com Subject: Re: ctrl-c In-Reply-To: <3592325D.7C2EF151@fys-hp-1.risoea.dka> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Thu, 25 Jun 1998, Carsten Svaneborg wrote: > Eli Zaretskii wrote: > > Use the library function `signal' to install a signal handler for the > > SIGINT signal. In the handler, call that particular function you want to > > be called. > How precisely do you do this? > Could you sketch a piece of code that trapped and handled some signal. You should really look up the description of the function `signal' in the library reference (type "info libc alpha signal" from the DOS prompt). A *really* sketchy fragment will be like this (UNTESTED!): #include ... void ctrl_c_handler (int signo) { static int ctrl_c_count = 0; if (signo == SIGINT) ctrl_c_count++; } ... int main (void) { ... signal (SIGINT, ctrl_c_handler); ... } Note that SIGINT is also generated by Ctrl-BREAK. If you need to distinguish these two, you will need to peek at the keyboard buffer inside the handler (when Ctrl-BREAK is pressed, the buffer is empty, or holds the key pressed before that, which isn't Ctrl-C). Again, please look in the library docs for the details. This issue is too complex to be described in a message.