liveBook · Manning

Quick_exit

As explained in Modern C, Third Edition

quick_exit is a C standard-library function that terminates a program after running functions registered for quick termination.

An alternative termination handler

void shortCleanup(void) { /* abbreviated cleanup */ } int main(void) { at_quick_exit(shortCleanup); quick_exit(1); } Passing shortCleanup without () registers the function rather than calling it immediately. quick_exit then terminates through the handlers registered with at_quick_exit. section 8.8

quick_exit uses a termination-handler list separate from the normal atexit list. It is an option when normal handlers take too long or termination must begin in a signal handler. Use it with care. section 8.8

TAKEAWAY — choose the termination path deliberately:

  • Normal termination uses atexit handlers; quick_exit uses handlers registered with at_quick_exit. section 8.8
  • _Exit runs neither application-specific handler list. abort also inhibits some system cleanup. section 8.8

In one signal-handler arrangement, SIGTERM leads to quick_exit and therefore runs the at_quick_exit cleanup list. SIGABRT instead leads to _Exit; SIGINT returns to the interrupted execution. section 19.6

How Modern C, Third Edition covers it

How deep it goes
Explains handler registration and contrasts termination paths, then illustrates signal-handler use without detailing quick_exit internals.
Examples
Shows function declarations and contrasts how SIGTERM, SIGABRT, and SIGINT affect control flow.
What you can do after
Operate/configure it by registering an alternative cleanup handler with at_quick_exit and choosing quick_exit deliberately.
How it connects
Connects quick_exit to at_quick_exit, atexit, _Exit, abort, and signal handlers.

Also explained in

Compare how 2 books explain quick_exit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.