Process Cleanups Via Exit Handlers Registered Using atexit function
Any normal Unix process can terminate in following ways:
- Graceful exit – Normal termination of process. For eg:
- Returning from main, calling exit etc.
- Ungraceful exit – Abnormal termination of process. For eg:
- Abort signal. Due to some fatal error etc.
_exit, _EXIT and exit functions can be used to terminate the process normally. Usually exit functions do the cleanup but if needed a programmer can also define its own exit handler functions to do some specific cleanup actions needed by the program.
(more…)