Atexit
atexit is a C standard-library function that registers a function to execute during normal program termination.
Modern C, Third Edition
atexit is a C standard-library function that registers a function to be called during normal program termination.
- How it is used
- Registers cleanup code for normal program termination.
- How deep it goes
- Defines registration and function-reference syntax, but deliberately omits detailed handler mechanics.
- Examples
- Demonstrates a sayGoodBye handler that reports errors and writes a farewell message.
- What you can do after
- Apply atexit to register memory cleanup or termination logging before normal program completion.
Modern C
atexit is the C standard library function that registers a function to be called during normal program termination.
- How it is used
- Registers cleanup or reporting code for normal program termination.
- How deep it goes
- Defines registration syntax and behavior through one example, but defers detailed function-parameter mechanics.
- Examples
- Uses a sayGoodBye handler that checks errno, reports errors, writes to stderr, and represents cleanup work.
- What you can do after
- Apply it by registering a no-argument handler for cleanup or status reporting during normal termination.
Related concepts
- call_oncecontrasts with · call_once is a threading operation that coordinates callers so a specified callback is successfully executed at most once for a given once-control object.
- exitconfigures · exit is a standard-library function that terminates normal program execution after performing required termination processing, without ordinarily unwinding active automatic objects.
- termination handleruses · A termination handler is an application-supplied function registered to execute during a program’s termination processing.
- callbackuses · A callback is a function or other callable supplied to software for invocation later in response to a specified event, condition, or point in execution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

