kexit

Langue: en

Version: 58956 (mandriva - 22/10/07)

Section: 2 (Appels système)

NAME

kexit, _kexit, atkexit - Terminate LAM process.

C SYNOPSIS

int kexit (int errcode);
int _kexit (int errcode);
int atkexit (int (*func)(), char *arg);

FORTRAN SYNOPSIS

subroutine KXIT (errcode)
integer errcode

DESCRIPTION

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.

RETURN VALUE

kexit() and _kexit() do not return. Upon successful completion, atkexit() returns 0. Otherwise, -1 is returned and the global variable errno is set to indicate the error.

ERRORS

ENOEXDESCRIPTORS
There is no room left in the internal table of exit functions.

BUGS

If too many user functions are registered with atkexit() before calling system functions that also call atkexit(), the latter calls to atkexit() may fail and some system functions may not be registered. If the missing exit function is for LAM stream file I/O, some output data may be lost.

SEE ALSO

kdetach(2), kenter(2)