2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 1997, The Open Group. All Rights Reserved.
45 .\" Portions Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
47 .TH ATEXIT 3C "May 25, 2001"
49 atexit \- register a function to run at process termination or object unloading
55 \fBint\fR \fBatexit\fR(\fBvoid (*\fR\fIfunc\fR)(void));
61 The \fBatexit()\fR function registers the function pointed to by \fIfunc\fR to
62 be called without arguments on normal termination of the program or when the
63 object defining the function is unloaded.
66 Normal termination occurs by either a call to the \fBexit\fR(3C) function or a
67 return from \fBmain()\fR. Object unloading occurs when a call to
68 \fBdlclose\fR(3C) results in the object becoming unreferenced.
71 The number of functions that may be registered with \fBatexit()\fR is limited
72 only by available memory (refer to the \fB_SC_ATEXIT_MAX\fR argument of
76 After a successful call to any of the \fBexec\fR(2) functions, any functions
77 previously registered by \fBatexit()\fR are no longer registered.
80 On process exit, functions are called in the reverse order of their
81 registration. On object unloading, any functions belonging to an unloadable
82 object are called in the reverse order of their registration.
86 Upon successful completion, the \fBatexit()\fR function returns 0. Otherwise,
87 it returns a non-zero value.
91 The \fBatexit()\fR function may fail if:
98 Insufficient storage space is available.
104 The functions registered by a call to \fBatexit()\fR must return to ensure that
105 all registered functions are called.
108 There is no way for an application to tell how many functions have already been
109 registered with \fBatexit()\fR.
113 See \fBattributes\fR(5) for descriptions of the following attributes:
121 ATTRIBUTE TYPE ATTRIBUTE VALUE
123 Interface Stability Standard
131 \fBexec\fR(2), \fBdlclose\fR(3C), \fBexit\fR(3C), \fBsysconf\fR(3C),