AT_SHUTDOWN(9)

NAME
at_shutdown, rm_at_shutdown - ask that a function be run at shutdown.

SYNOPSIS
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/reboot.h>
typedef void *bootlist_fnint howto, void *arg
int
at_shutdown(bootlist_fn func, void *arg, int when);
int
rm_at_shutdown(bootlist_fn func, void *arg);

DESCRIPTION
The at_shutdown facility allows a kernel module to ensure that it is notified at system shutdown. The function func is called with the flags indicating boot type, and the opaque argument arg when the system is shut down.

If the requirement for notification is removed, then the function rm_at_shutdown() must be called with the exact func and arg arguments as the corresponding call to at_shutdown(). There are two shutdown queues, one run before the final sync and one after. The last argument to at_shutdown should be one of SHUTDOWN_PRE_SYNC or SHUTDOWN_POST_SYNC to specify which queue should be used. rm_at_shutdown() will remove an entry from either queue.

RETURN VALUES
at_shutdown() returns an error code, 0 meaning success. rm_at_shutdown() returns the number of items removed (should be 0 or 1).

SEE ALSO
reboot(2), boot(9)

HISTORY
The at_shutdown() and rm_shutdown() functions appeared in FreeBSD 2.2.

BUGS
Since the shutdown 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)