add ANSI contribution notice
[unix-history] / usr / src / lib / libc / stdlib / atexit.3
CommitLineData
ae59e04c 1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
cd1a8d59
KB
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
043368e6
KB
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
cd1a8d59
KB
8.\" %sccs.include.redist.man%
9.\"
043368e6 10.\" @(#)atexit.3 5.3 (Berkeley) %G%
cd1a8d59 11.\"
ae59e04c
CL
12.Dd
13.Dt ATEXIT 3
14.Os
15.Sh NAME
16.Nm atexit
17.Nd register a function to be called on exit
18.Sh SYNOPSIS
19.Fd #include <stdlib.h>
20.Ft int
21.Fn atexit "void (*function)(void)"
22.Sh DESCRIPTION
23The
24.Fn atexit
25function
cd1a8d59 26registers the given
ae59e04c 27.Ar function
cd1a8d59 28to be called at program exit, whether via
ae59e04c 29.Xr exit 3
cd1a8d59 30or via return from the program's
ae59e04c 31.Em main .
cd1a8d59
KB
32Functions so registered are called in reverse order;
33no arguments are passed.
34At least 32 functions can always be registered,
35and more are allowed as long as sufficient memory can be allocated.
ae59e04c
CL
36.Sh RETURN VALUES
37.Rv -std atexit
38.Sh ERRORS
39.Bl -tag -width [ENOMEM]
40.It Bq Er ENOMEM
cd1a8d59
KB
41No memory was available to add the function to the list.
42The existing list of functions is unmodified.
ae59e04c
CL
43.El
44.Sh SEE ALSO
45.Xr exit 3
46.Sh STANDARDS
47The
48.Fn atexit
49function
50conforms to
51.St -ansiC .