atexit registers a function to run during normal program termination. The registration passes the function itself, so write atexit(sayGoodBye), not atexit(sayGoodBye()). section 8.7
Registering a termination handler
void sayGoodBye(void) { if (errno) perror("terminating with error condition"); fputs("Good Bye\n", stderr); } int main(int argc, char* argv[argc+1]) { atexit(sayGoodBye); ... } After normal termination, sayGoodBye reports the status and can perform cleanup such as freeing memory or writing a timestamp. section 8.7
Use termination handlers with these constraints:
- Prefer ordinary exit and preserve library cleanup unless bypassing it is necessary. section 8.7
- Use quick_exit and at_quick_exit only when the normal handler list is too time-consuming. section 8.7

