//------------------------------------------------------------------------------ // A simplified demonstration of signal handling; part 2 #include // Libraries which may be needed #include #include struct sigaction sigaction_structure; // A data structure, filled in below void escape(); // Declaration only - definition below //------------------------------------------------------------------------------ int main (int argc, char *argv[]) // Start here { // Set three fields in a predefined 'struct' sigaction_structure.sa_handler = &escape; // Pointer to a -function- sigemptyset(&sigaction_structure.sa_mask); // Call defines 'empty' field sigaction_structure.sa_flags = 0; // No flags // Link the structure to signal "SIGINT" (as generated by ^C) sigaction(SIGINT, &sigaction_structure, NULL);// Link while (0 == 0); // Everlasting loop? exit(0); // Unreachable! } //------------------------------------------------------------------------------ void escape(int signum) { printf("\nAargh - you got me!\n"); exit(0); } //------------------------------------------------------------------------------