std::_Exit(3)
π¦ std::_Exit(3) π¦
okay so bestie, welcome to std::_Exit(3) from the C++ Standard Libary β yes, that's the manual name, and this page is about the most βI'm out, no cleanupβ function ever. no cap π«Ά
π NAME π
std::_Exit β literally std::_Exit, that's the name, bestie π
β¨ Synopsis β¨
Defined in header <cstdlib>
[[noreturn]] void _Exit( int exit_code ) noexcept; (since C++11)
π Description π
So here's the tea: std::_Exit causes normal program termination to occur without completely cleaning the resources. it's giving βwe're leaving right now, no packingβ π¨
Destructors of variables with automatic, thread local and static storage durations are not called. Functions passed to std::at_quick_exit() or std::atexit() are not called. Whether open resources such as files are closed is implementation defined. important caveat, bestie β that last bit is not something this page promises.
If exit_code is 0 or EXIT_SUCCESS, an implementation-defined status indicating successful termination is returned to the host environment. If exit_code is EXIT_FAILURE, an implementation-defined status, indicating unsuccessful termination, is returned. In other cases implementation-defined status value is returned. implementation-defined girlies, you know how it is πΈ
π Parameters π
exit_codeβ exit status of the program. that's the whole parameter list, bestie π
π Return value π
(none) β literally nothing comes back, it's a [[noreturn]] situation, so don't wait up π
π» Example π»
// Run this code β go go go:
// Run this code
#include <iostream>
class Static
{
public:
~Static()
{
std::cout << "Static dtor\n";
}
};
class Local
{
public:
~Local()
{
std::cout << "Local dtor\n";
}
};
Static static_variable; // dtor of this object will *not* be called
void atexit_handler()
{
std::cout << "atexit handler\n";
}
int main()
{
Local local_variable; // dtor of this object will *not* be called
// handler will *not* be called
const int result = std::atexit(atexit_handler);
if (result != 0)
{
std::cerr << "atexit registration failed\n";
return EXIT_FAILURE;
}
std::cout << "test" << std::endl; // flush from std::endl
// needs to be here, otherwise nothing will be printed
std::_Exit(EXIT_FAILURE);
}
π Output: π
test
π See also π
abortβ causes abnormal program termination (without cleaning up) (function) πexitβ causes normal program termination with cleaning up (function) π§- C documentation for
_Exitβ yes, the C docs, go look bestie π
mwah π this lil page comes from http://cppreference.com, version/date 2024.06.10, and the page is literally std::_Exit(3) β byeee β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms