Registering an exit handler does not guarantee that it will run: atexit(sayGoodBye); ... abort(); abort terminates the program abnormally, bypassing application-specific atexit handlers and some system cleanup. TAKEAWAY: use it with extreme care. section 8.7
The termination functions differ in how much cleanup they preserve:
- quick_exit runs handlers registered with at_quick_exit. section 8.7
- _Exit suppresses application-specific handlers but permits platform-specific cleanup such as file closure. section 8.7
- abort is more intrusive because it also inhibits some system cleanup. section 8.7
Runtime assertion failure
When assert detects a condition that should always hold, it prints a diagnostic and calls abort. A failure can expose a false assumption during debugging, but such assertions and messages should not remain in a production executable. section 8.7
