A LAM process that calls kenter(2) must call
kexit()
to terminate.
kexit()
calls all registered LAM exit functions before informing
the local daemon of its death.
_kexit()
may be used instead of
kexit()
to avoid calling the exit functions.
The argument to
kexit()
and
_kexit()
is an exit code which is sent in a message to the parent process, if requested
by the parent process when the process was created.
See rploadgo(2) and rpwait(2).
By convention the exit code is 0 if the process successfully completed.
An exit function is registered by calling
atkexit() .
The arguments passed to
atkexit()
are the address of the exit function to be called upon
kexit() ,
and an argument to pass to the exit function when it is called.
(Note that the function may ignore the argument, reverting to the
ANSI standard C library atexit(3) behavior, where no argument is passable.)
There is a limit on how many exit functions may be registered.
Exit functions are called in reverse order of their registration.
Some system modules register their own cleanup functions.
kexit()
eventually calls kdetach(2) to gracefully detach from the LAM
daemon and exit(3) to actually terminate within the host operating system.