1atexit(3C) Standard C Library Functions atexit(3C)
2
3
4
6 atexit - register a function to run at process termination or object
7 unloading
8
10 #include <stdlib.h>
11
12 int atexit(void (*func)(void));
13
14
16 The atexit() function registers the function pointed to by func to be
17 called without arguments on normal termination of the program or when
18 the object defining the function is unloaded.
19
20
21 Normal termination occurs by either a call to the exit(3C) function or
22 a return from main(). Object unloading occurs when a call to
23 dlclose(3C) results in the object becoming unreferenced.
24
25
26 The number of functions that may be registered with atexit() is limited
27 only by available memory (refer to the _SC_ATEXIT_MAX argument of
28 sysconf(3C)).
29
30
31 After a successful call to any of the exec(2) functions, any functions
32 previously registered by atexit() are no longer registered.
33
34
35 On process exit, functions are called in the reverse order of their
36 registration. On object unloading, any functions belonging to an
37 unloadable object are called in the reverse order of their registra‐
38 tion.
39
41 Upon successful completion, the atexit() function returns 0. Otherwise,
42 it returns a non-zero value.
43
45 The atexit() function may fail if:
46
47 ENOMEM Insufficient storage space is available.
48
49
51 The functions registered by a call to atexit() must return to ensure
52 that all registered functions are called.
53
54
55 There is no way for an application to tell how many functions have
56 already been registered with atexit().
57
59 See attributes(5) for descriptions of the following attributes:
60
61
62
63
64 ┌─────────────────────────────┬─────────────────────────────┐
65 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
66 ├─────────────────────────────┼─────────────────────────────┤
67 │Interface Stability │Standard │
68 ├─────────────────────────────┼─────────────────────────────┤
69 │MT-Level │Safe │
70 └─────────────────────────────┴─────────────────────────────┘
71
73 exec(2), dlclose(3C), exit(3C), sysconf(3C), attributes(5)
74
75
76
77SunOS 5.11 25 May 2001 atexit(3C)