I Hate Segmentation Faults

I haveĀ  been coding in C for four years now. Any C user knows the segmentation fault error. And trust me, there cannot possibly be anything worse than seeing your program terminate with a seg fault message. It irritates me so much that in my B Tech Project program I have created a signal handler which catches the error and prints a happy message instead of the boring default message.

This is what I have done :

// Include signal.h for signal handling
#include <signal .h>

/**
  * The function which is called upon a seg fault
  */
void SignalHandler(int sig) {
  printf("\n\nHave a happy time debugging. Good luck :D \n\n");
  exit(-1);
  return;
}

/**
  * The main function. Declare the signal handler here.
  */
int main(int argc, char *argv[]) {
  signal(SIGSEGV, SignalHandler);

  /**
    * Do whatever you want to
    */

  return 0;
}

:) . I know this doesn’t do anything, but atleast I do not feel frustrated now.

Popularity: 2% [?]

Related posts:

  1. A Logger In C
  2. Bitwise 2009 Engima Answers
  3. I Hate Feeling So Helpless
  4. Modes Of Encryption
  5. Variadic Functions

2 Responses to “I Hate Segmentation Faults”


Leave a Reply