c++ - boost::thread_specific_ptr/cleanup 与 atexit 执行顺序

标签 c++ ssl pthreads

如果多线程应用程序被 exit(x) 或从 main 中“返回”终止——处理程序的执行顺序是什么?

  1. 由 atexit 注册的处理程序
  2. pthread_key_create/thread_specific_ptr 清理处理程序(所谓的析构函数)

还是相反?

谢谢。

最佳答案

来自 http://www.cplusplus.com/reference/cstdlib/atexit :

If more than one atexit function has been specified by different calls to this function, they are all executed in reverse order as a stack (i.e. the last function specified is the first to be executed at exit).

关于c++ - boost::thread_specific_ptr/cleanup 与 atexit 执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37784616/

相关文章:

java - 无法将套接字转换为 TLS

c++ - 未找到 Windows7 pthread.h

C++:在按 ENTER 之前读取字符

c++ - MacOSX上的IOstream

c++ - 您如何将单元测试引入大型的遗留 (C/C++) 代码库?

apache - 两个 VirtualHosts 通过 https(运行 Redmine 等)

email - 使用 codeigniter 框架的 gmail smtp 在我的主机中不工作

c++ - jsoncpp operator= 中的 undefined reference

c - Apache 2.4 MPM worker : Thread Init?

c++ - C++ 中的并行 CRC32