Segment errors or other errors that cause the program to quit has always been like an unreasonable bounder, the process of our painstaking development of wanton destruction, leaving a big or small core files let us have a headache, we wept after the silent bear this sorrow ...
Segment error generated by the SIGEGV, can be captured by the user, also gives us the opportunity to save the program important data, borrow glibc a function to deal with a SIGEGV idea, we can turn the segment error into a core file will produce a normal exit.
1. Register SIGEGV processing Process Egv_handler.
The 2.SIGEGV process Egv_handler first saves the program's key data and persists the necessary data.
3.egv_handler finally restores the SIGEGV default processing action and re-throws the SIGEGV signal.
The third step of the code
/* Pass on the signal (so-a core file is produced). */
Sa.sa_handler = SIG_DFL;
Sigemptyset (&sa.sa_mask);
sa.sa_flags = 0;
Sigaction (signal, &SA, NULL);
Raise (signal);
This paragraph error on the program is no longer a threat, spit groove, I really do not like elegant this adjective, programmers and programs are rational code, with so emotional load forced vocabulary, I was moved to vomit.
Make paragraph errors more elegant