Hi,

Sure you just need to have a signal handler in your program.

For instance:

#include <signal.h>

int catch_signal(); /* Prototype function */

int main()
{
.
.
.
/*
 * Setup to catch interrupt (^C)
 */

signal(SIGINT, catch_signal);

.
.
} /* END: main() */

int catch_signal()
{

printf("\n\nCleaning up.....\n");

.
.
.

printf("bye!\n\n");

exit(0);

}

You can NOT handle SIGKILL!

Good luck!

John Gorman

On 16 Jun 98, at 0:17, James wrote:

> is it possible to have a function called when the user presses ^C or kills
> the program so that the program can 'clean up' before being terminated?
> (i.e close all open files, write out data, free allocated memory etc). if
> so, how?
> 
> -[[EMAIL PROTECTED]]--------------------------------------------
> ----- Http://x-map.home.ml.org                  Mailto :
> [EMAIL PROTECTED] ---[Quote Of The
> Day]---------------------------------------------------------- Kansas
> state law requires pedestrians crossing the highways at night to wear tail
> lights.
> --------------------------------------------------------------------------
> -----
> 


Reply via email to