调用exit()时,析构函数是否运行? [英] Are destructors run when calling exit()?
问题描述
在C ++中,当应用程序调用exit(3)时,栈上的析构函数应该运行到unwind
$ b b
基本上,当 exit
被调用时静态对象被销毁,执行 atexit
处理程序,刷新和关闭,并删除由 tmpfile
创建的文件。本地自动对象不会被销毁。
调用 abort
会让更少发生:无需清理。
干杯& hth。,
Possible Duplicate:
Will exit() or an exception prevent an end-of-scope destructor from being called?
In C++, when the application calls exit(3) are the destructors on the stack supposed to be run to unwind the stack?
C++98 §18.3/8 discusses this.
Essentially, when exit
is called static objects are destroyed, atexit
handlers are executed, open C streams are flushed and closed, and files created by tmpfile
are removed. Local automatic objects are not destroyed. I.e., no stack unwinding.
Calling abort
lets even less happen: no cleanup whatsoever.
Cheers & hth.,
这篇关于调用exit()时,析构函数是否运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!