AT_EXIT(9)

NAME
at_exit, rm_at_exit - ask that a function be run at exit.

SYNOPSIS
#include <sys/systm.h>
typedef void *exitlist_fn struct proc *;
int
at_exit(exitlist_fn func);
int
rm_at_exit(exitlist_fn func);

DESCRIPTION
The at_exit facility allows a kernel module to ensure that it is notified at any process exit. The function func is called with the a pointer to the exiting process's proc structure.

If the requirement for notification is removed, then the function rm_at_exit() must be called with the exact func argument as the corresponding call to at_exit().

RETURN VALUES
The at_exit function returns an errno, 0 meaning success. The rm_at_exit() function returns the number of items removed (should be 0 or 1).

SEE ALSO
_exit(2)

HISTORY
The at_exit() function appeared in FreeBSD 2.2.

BUGS
Since the exit queue is not sorted and items are added to the head, order of execution is reversed to that of insertion.

AUTHORS
The function was written by Julian Elischer (julian@freebsd.org)