std::_Exit
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <cstdlib> で定義
|
||
[[noreturn]] void _Exit( int exit_code ) noexcept; |
(C++11以上) | |
リソースの完全なクリーンを行わずにプログラムの正常終了を発生させます。
自動、スレッドローカル、静的記憶域期間を持つ変数のデストラクタは呼ばれません。 std::at_quick_exit() または std::atexit() に渡した関数は呼ばれません。 ファイルのような開いているリソースが閉じられるかどうかは処理系定義です。
exit_code が 0 または EXIT_SUCCESS であれば、成功終了を表す処理系定義のステータスがホスト環境に返されます。 exit_code が EXIT_FAILURE であれば、失敗終了を表す処理系定義のステータスが返されます。 それ以外の場合は、処理系定義のステータス値が返されます。
引数
| exit_code | - | プログラムの終了ステータス |
戻り値
(なし)
例
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);
}
出力:
test
関連項目
| (クリーンアップせずに) プログラムを異常終了させます (関数) | |
| クリーンアップをしてプログラムを正常終了させます (関数) | |
_Exit の C言語リファレンス
| |