.TH EXIT 3 .CT 2 proc_man .SH NAME exit, onexit \(mi terminate process .SH SYNOPSIS .nf .B void exit(status) .B int status; .PP .B int onexit(fn) .B int (*fn)(); .fi .SH DESCRIPTION .I Exit is the conventional way to terminate a process. Before calling .I _exit (see .IR exit (2)) with .I status as an argument, it calls in reverse order all the functions recorded by .IR onexit . .PP .I Exit can never return. .PP .I Onexit records .I fn as a function to be called by .IR exit . It returns zero if it failed, nonzero otherwise. Typical uses include cleanup routines for .IR stdio (3) and profiling; see .IR monitor (3). .PP Calling .I onexit twice (or more) with the same function argument causes .I exit to invoke the function twice (or more). .PP The function .I fn should be declared as .EX int fn() .EE .PP The constant .B NONEXIT defined in .B determines how many functions can be recorded. .SH "SEE ALSO" .IR exit (2)