Does the stack expand when SIGABRT occurs?

Does the stack expand (destructors start) when SIGABRT is encountered in C ++?

Thanks.

+3
source share
5 answers

This answer indicates that destructors are not called.

+2
source
<Not p> No:
$ 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
+4
source

, . POSIX, C API, " ++, ".

+1

man- signal(3) Mac OS X

  No    Name         Default Action       Description
...
 6     SIGABRT      create core image    abort program (formerly SIGIOT)

, ...

0
source

The SIGABRT signal is used to create the main application launch file for a while. We have been using this signal for some time to debug the application. And as far as I know, destructors are not called by this signal.

0
source

Source: https://habr.com/ru/post/1725244/


All Articles