-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExitFunctions.cpp
89 lines (72 loc) · 1.73 KB
/
ExitFunctions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* \file ExitFunctions.cpp
* \brief
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
void onExit()
{
STD_TRACE_FUNC;
}
//-------------------------------------------------------------------------------------------------
void onQuickExit()
{
STD_TRACE_FUNC;
}
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
constexpr int exitCode {10};
std::atexit(onExit);
std::at_quick_exit(onQuickExit);
std::cout << "------------------------------" << std::endl;
{
std::cout << "::exit(exitCode)" << std::endl;
std::exit(exitCode);
}
{
std::cout << "std::_Exit(exitCode)" << std::endl;
std::_Exit(exitCode);
}
{
std::cout << "::_exit(exitCode)" << std::endl;
::_exit(exitCode);
}
{
std::cout << "std::quick_exit(exitCode)" << std::endl;
std::quick_exit(exitCode);
}
{
std::cout << "std::abort()" << std::endl;
std::abort();
}
{
std::cout << "std::terminate()" << std::endl;
std::terminate();
}
STD_TRACE_FUNC;
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
------------------------------
::exit(exitCode)
::: onExit :::
------------------------------
::_Exit(exitCode)
------------------------------
::_exit(exitCode)
------------------------------
std::quick_exit(exitCode)
::: onQuickExit :::
------------------------------
std::abort()
Aborted (core dumped)
------------------------------
std::terminate()
terminate called without an active exception
Aborted (core dumped)
------------------------------
#endif