Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some practical applications of the quick_exit and at_quick_exit functions?

Tags:

c

exit

I've come across at_quick_exit and quick_exit while going over stdlib.h and looking for functions that I haven't implemented.

I don't understand the point of having these two functions. Do they have any practical usage?

like image 944
S.S. Anne Avatar asked Sep 06 '19 23:09

S.S. Anne


1 Answers

Basically it exists in C because of C++. The relevant document from WG 14 C standard committe can be found here.

The document was adapted from the paper accepted by the C++ standard. The idea behind quick_exit is to exit the program without canceling all threads and without executing destructors of static objects. C doesn't has language support for such things as "destructors" at all and the thread support library in C is almost nowhere implemented. The at_quick_exit and quick_exit functions have very little to no meaning at all in C.

In C there is a function _Exit that causes normal program termination to occur and control to be returned to the host environment, but is not required to flush open file descriptors, write unbuffered data, close open files, as opposed to exit(). Basically the at_quick_exit and quick_exit functions are facilities build to run custom user handles and then execute _Exit, while atexit is a facility to execute custom handlers upon calling exit().

like image 133
KamilCuk Avatar answered Nov 15 '22 05:11

KamilCuk