EXIT(3) — UNIX Programmer’s Manual
NAME
exit, on_exit − terminate a process after tidying up
SYNOPSIS
exit(status)
int status;
on_exit(func, data)
void (∗func)();
int data;
DESCRIPTION
Exit terminates a process after calling any functions registered with on_exit and then the Standard I/O library function _cleanup to flush any buffered output. Exit never returns.
On_exit is used to register a procedure to be called during the exit sequence. Data is given to the called procedure as a parameter.
DIAGNOSTICS
On_exit returns 0 if the registration happened, or -1 if there are already a maximum number of registered procedures.
SEE ALSO
BUGS
A maximum of four (4) functions can be registered with on_exit.
If the process terminates without calling exit (by directly calling _exit(2) or by an untrapped signal) then neither _cleanup, nor any of the registered procedures are called.
4.2 Berkeley Distribution — Revision 1.3 of 29/10/88