当 C++ 中出现 SIGABRT 时,堆栈是否展开(析构函数运行)?
谢谢。
最佳答案
否:
$ cat test.cc
#include <iostream>
#include <sys/types.h>
#include <signal.h>
class Test {
public:
~Test() { std::cout << "~Test called" << std::endl; }
};
int main(int argc, char *argv[])
{
Test t = Test();
if (argc > 1) {
kill(0, SIGABRT);
}
return 0;
}
$ g++ test.cc
$ ./a.out
~Test called
$ ./a.out 1
Aborted
关于c++ - 当 SIGABRT 发生时,堆栈会被展开吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1878539/