A bug in the application that caused a crash at runtime? My God, how is this possible?
Unfortunately, to the well-heeled software veteran, though, this is not a big surprise. Bugs exist; they can hide really well, for years, sometimes; one day, they come out and—bang!—the process crashes.
Here, our intention is not to discuss debugging techniques or tools (let's save that for another book perhaps, shall we?); instead, it's this key point: if our application process does crash, can we do something? Certainly: in the previous chapter, we have learned in detail how we can trap signals. Why not design our application such that we trap the typical fatal signals—the SIGBUS, SIGFPE, SIGILL, and SIGSEGV—and, in their signal handler(s), perform useful tasks such as these:
- Perform critical application cleanup&...