1*48350Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California. 242098Sbostic.\" All rights reserved. 342098Sbostic.\" 442098Sbostic.\" This code is derived from software contributed to Berkeley by 542098Sbostic.\" Chris Torek. 642098Sbostic.\" %sccs.include.redist.man% 742098Sbostic.\" 8*48350Scael.\" @(#)atexit.3 5.2 (Berkeley) 04/19/91 942098Sbostic.\" 10*48350Scael.Dd 11*48350Scael.Dt ATEXIT 3 12*48350Scael.Os 13*48350Scael.Sh NAME 14*48350Scael.Nm atexit 15*48350Scael.Nd register a function to be called on exit 16*48350Scael.Sh SYNOPSIS 17*48350Scael.Fd #include <stdlib.h> 18*48350Scael.Ft int 19*48350Scael.Fn atexit "void (*function)(void)" 20*48350Scael.Sh DESCRIPTION 21*48350ScaelThe 22*48350Scael.Fn atexit 23*48350Scaelfunction 2442098Sbosticregisters the given 25*48350Scael.Ar function 2642098Sbosticto be called at program exit, whether via 27*48350Scael.Xr exit 3 2842098Sbosticor via return from the program's 29*48350Scael.Em main . 3042098SbosticFunctions so registered are called in reverse order; 3142098Sbosticno arguments are passed. 3242098SbosticAt least 32 functions can always be registered, 3342098Sbosticand more are allowed as long as sufficient memory can be allocated. 34*48350Scael.Sh RETURN VALUES 35*48350Scael.Rv -std atexit 36*48350Scael.Sh ERRORS 37*48350Scael.Bl -tag -width [ENOMEM] 38*48350Scael.It Bq Er ENOMEM 3942098SbosticNo memory was available to add the function to the list. 4042098SbosticThe existing list of functions is unmodified. 41*48350Scael.El 42*48350Scael.Sh SEE ALSO 43*48350Scael.Xr exit 3 44*48350Scael.Sh STANDARDS 45*48350ScaelThe 46*48350Scael.Fn atexit 47*48350Scaelfunction 48*48350Scaelconforms to 49*48350Scael.St -ansiC . 50