EXITS(2)
NAME
exits, atexit, atexitdont − terminate process, process cleanup
SYNOPSIS
void_exits(char ∗msg)
voidexits(char ∗msg)
intatexit(void(∗)(void))
voidatexitdont(void(∗)(void))
DESCRIPTION
Exits is the conventional way to terminate a process. _Exits is the underlying system call. They can never return.
Msg conventionally includes a brief (maximum length ERRLEN) explanation of the reason for exiting, or a null pointer or empty string to indicate normal termination. The string is passed to the parent process, prefixed by the name and process id of the exiting process, when the parent does a wait(2).
Before calling _exits with msg as an argument, exits calls in reverse order all the functions recorded by atexit.
Atexit records fn as a function to be called by exits. It returns zero if it failed, nonzero otherwise. A typical use is to register a cleanup routine for an I/O package.
Calling atexit twice (or more) with the same function argument causes exits to invoke the function twice (or more).
There is a limit to the number of exit functions that will be recorded; atexit returns 0 if that limit has been reached.
Atexitdont cancels a previous registration of an exit function, which is useful after a fork(2) to avoid conflicting calls of an exit function
SEE ALSO
Plan 9 — January 03, 1993