mardi 28 mars 2017

How to exit a process without any unwinding in C++98?

In C++11 or later, we can call std::quick_exit to exit a process without any unwinding, that is, no destructor will be called [after | during] std::quick_exit.

I have a project:

  1. It has a global object, and there is a fatal bug in the destructor of the global object;
  2. I have no access to the source of the global object;
  3. If I can call std::quick_exit at the last line of main function, the bug won't be triggered;
  4. For some reason, the project must be compiled with a C++98 compiler; that is to say, I cannot call std::quick_exit in a C++98 compiler.

In short:

What function in C++98 is equivalent to C++11's std::quick_exit?

Under Windows, I can call ExitProcess(0) to forcibly exit a process without any cleanup.

What's the counterpart under Linux?

Aucun commentaire:

Enregistrer un commentaire