]> pd.if.org Git - pdclib.old/blob - man3/exit.3
Add _cbprintf/_vcbprintf (callback based printf formatters)
[pdclib.old] / man3 / exit.3
1 .\" This file is part of the Public Domain C Library (PDCLib).\r
2 .\" Permission is granted to use, modify, and / or redistribute at will.\r
3 .\"\r
4 .Dd\r
5 .Dt exit 3\r
6 .Os\r
7 .\"\r
8 .Sh NAME\r
9 .Nm exit\r
10 .Nd terminates the process\r
11 .\"\r
12 .Sh SYNOPSIS\r
13 .In stdlib.h\r
14 .Fn "noreturn void exit" "int status"\r
15 .Fn "noreturn void quick_exit" "int status"\r
16 .Fn "noreturn void _Exit" "int exitcode"\r
17 .\"\r
18 .Sh DESCRIPTION\r
19 Calling any of these three functions terminates the current process, returning \r
20 the exit code passed as a parameter. The interpretation of the exit code is \r
21 undefined, except that 0 or\r
22 .Dv EXIT_SUCCESS\r
23 shall indicate successful completion and\r
24 .Dv EXIT_FAILURE\r
25 shall indicate a non-successful completion.\r
26 .\"\r
27 .Pp\r
28 .Fn exit\r
29 first destroys all objects with C++ thread local storage duration (the C \r
30 standard leaves whether or not thread local objects are destroyed or not \r
31 undefined). Next, the destructors of all C++ objects of static storage duration \r
32 are invoked along with all functions passed to\r
33 .Fn atexit \r
34 in reverse order of registration (the time of registration for C++ objects of \r
35 static storage duration is taken to be the time at which the constructor \r
36 completes). It then flushes all open\r
37 .Vt FILE\r
38 streams with unwritten data and closes them. Finally, files created by\r
39 .Fn tmpfile\r
40 are removed, before handing control back to the host environment. Note in \r
41 particular that functions registered with\r
42 .Fn at_quick_exit\r
43 are\r
44 .Sy not\r
45 called.\r
46 .\"\r
47 .Pp\r
48 .Fn quick_exit\r
49 invokes any functions registered with\r
50 .Fn at_quick_exit\r
51 in reverse order of registration, then returns control to the host \r
52 environment by calling\r
53 .Fn _Exit .\r
54 No signal handlers are called, nor are any functions registered with\r
55 .Fn atexit .\r
56 .\"\r
57 .Pp\r
58 .Fn _Exit\r
59 returns control to the controlling environment without invoking any functions\r
60 registered by\r
61 .Fn atexit ,\r
62 .Fn at_quick_exit ,\r
63 any signal handlers, or the destructors of any thread local objects or C++ \r
64 objects of static storage duration. Whether or not any open \r
65 .Vt FILE\r
66 streams with unwritten data are flushed or not is undefined.\r
67 .\"\r
68 .Pp\r
69 The result of aborting a call to \r
70 .Fn exit\r
71 or\r
72 .Fn quick_exit\r
73 by use of \r
74 .Fn longjmp\r
75 is undefined. If any function or destructor invoked by\r
76 .Fn exit\r
77 or\r
78 .Fn quick_exit\r
79 should throw, \r
80 .Fn std::terminate\r
81 is invoked.\r
82 .\"\r
83 .Pp\r
84 Undefined behaviour results if, while a call to\r
85 .Fn exit\r
86 or\r
87 .Fn quick_exit\r
88 is in progress, a call to \r
89 .Fn exit\r
90 or\r
91 .Fn quick_exit\r
92 is made. \r
93 .\"\r
94 .Sh IMPLEMENTATION NOTES\r
95 PDCLib implements the process of flushing streams in\r
96 .Fn _Exit ,\r
97 and therefore\r
98 .Fn exit\r
99 calls it after all\r
100 .Fn atexit\r
101 handlers have been invoked.\r
102 .\"\r
103 .Sh SEE ALSO\r
104 .Xr abort 3\r
105 .Xr atexit 3\r
106 .Xr at_quick_exit 3\r
107 .\"\r
108 .Sh STANDARDS\r
109 .Fn exit\r
110 is first defined in\r
111 .St -isoC-90 ;\r
112 .Fn _Exit\r
113 was introduced in\r
114 .St -isoC-99 .\r
115 .Fn quick_exit\r
116 was introduced in\r
117 .St -isoC-11 \r
118 and\r
119 ISO/IEC 14882:2011 "C++ 2011" .