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:
std::quick_exit
at the last line of main
function, the bug won't be triggered;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?
You can use abort()
from <cstdlib>
. It sends a SIGABRT
to a process and if the signal is not caught the program is terminated without calling any destruction routines like atexit()
or any destructors.
More info here: link
Edit: std::quick_exit
exits normally, whereas calling abort()
results in abnormal termination, don't know if that's a problem.