coding >> listening to posix style signals (39 views)

A quick self reminder.

#include <stdio.h>
#include <string.h>
#include <signal.h>
 
void handler(int signal)
{
    printf("Signal: %s\n", strsignal(signal));
    if (signal == SIGABRT)
    {
	raise(SIGKILL); // can't be caught or ignored
    }
}
 
int main(int argc, char *argv[])
{
    signal(SIGABRT, handler); // Abort
    signal(SIGFPE, handler);  // Floating-Point Exception
    signal(SIGILL, handler);  // Illegal Instruction
    signal(SIGINT, handler);  // Interrupt
    signal(SIGSEGV, handler); // Segmentation Violation
    signal(SIGTERM, handler); // Terminate
    signal(SIGQUIT, handler); // Terminal quit
 
    printf("Hello Crazy World!\n");
 
    raise(SIGABRT); // raise Abort
 
    printf("I am never going to be printed...\n");
 
    return 0;
}

 

Leave a Comment or Trackback from your own site.

2 Responses to “listening to posix style signals”

  1. TV DVD Set says:

     If you successfully flee a zombie, you get your flee value’s worth of scavenging points. With these scavenging points, players turn their attention to the swag pile (which also varies in size depending on the number of players) which consists of piles of cards with different abilities.

  2. ysl outlet says:

    The endure date involves the superior individual Louis Vuitton replica and all our replica handbags to annihilate sub-standard items.

Leave a Reply