quick_exit 和 at_quick_exit 函数有哪些实际应用?
What are some practical applications of the quick_exit and at_quick_exit functions?
我在浏览 stdlib.h
并寻找我尚未实现的功能时遇到了 at_quick_exit
和 quick_exit
。
我不明白拥有这两个功能有什么意义。它们有实际用途吗?
它们基本上没有实际用途。其意图似乎是,一个可能具有重要的重要 atexit
处理程序的函数可以使用 quick_exit
退出,并且只调用此类处理程序的最小子集(它通过调用 at_quick_exit
定义) ,在调用所有 atexit
处理程序可能不安全的情况下。它也可以从信号处理程序中调用,但在这种情况下,您似乎无法从 at_quick_exit
处理程序中执行任何有意义的操作。
基本上是因为C++才存在于C中。 WG 14 C标准委员会的相关文件可以找到here。
该文档改编自 C++ 标准接受的论文。 quick_exit
背后的想法是 退出程序而不 取消所有线程并且 不 执行静态对象的析构函数。 C 根本没有对 "destructors" 之类的语言支持,而且 thread support library in C 几乎没有实现。 at_quick_exit
和 quick_exit
函数在 C 中几乎没有任何意义。
在 C 中有一个函数 _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()
。基本上 at_quick_exit
和 quick_exit
函数是构建到 运行 自定义用户句柄然后执行 _Exit
的工具,而 atexit
是在调用时执行自定义处理程序的工具exit()
.
我在浏览 stdlib.h
并寻找我尚未实现的功能时遇到了 at_quick_exit
和 quick_exit
。
我不明白拥有这两个功能有什么意义。它们有实际用途吗?
它们基本上没有实际用途。其意图似乎是,一个可能具有重要的重要 atexit
处理程序的函数可以使用 quick_exit
退出,并且只调用此类处理程序的最小子集(它通过调用 at_quick_exit
定义) ,在调用所有 atexit
处理程序可能不安全的情况下。它也可以从信号处理程序中调用,但在这种情况下,您似乎无法从 at_quick_exit
处理程序中执行任何有意义的操作。
基本上是因为C++才存在于C中。 WG 14 C标准委员会的相关文件可以找到here。
该文档改编自 C++ 标准接受的论文。 quick_exit
背后的想法是 退出程序而不 取消所有线程并且 不 执行静态对象的析构函数。 C 根本没有对 "destructors" 之类的语言支持,而且 thread support library in C 几乎没有实现。 at_quick_exit
和 quick_exit
函数在 C 中几乎没有任何意义。
在 C 中有一个函数 _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()
。基本上 at_quick_exit
和 quick_exit
函数是构建到 运行 自定义用户句柄然后执行 _Exit
的工具,而 atexit
是在调用时执行自定义处理程序的工具exit()
.