The shutdownhook_establish API is deprecated.
The
shutdownhook_establish() function adds
fn to the list of hooks invoked by
doshutdownhooks(9) at shutdown. When invoked, the hook function
fn will be passed
arg as its only argument.
The
shutdownhook_disestablish() function removes the hook described by the opaque pointer
cookie from the list of hooks to be invoked at shutdown. If
cookie is invalid, the result of
shutdownhook_disestablish() is undefined.
Shutdown hooks should be used to perform one-time activities that must happen immediately before the kernel exits. Because of the environment in which they are run, shutdown hooks cannot rely on many system services (including file systems, and timeouts and other interrupt-driven services), or even basic system integrity (because the system could be rebooting after a crash).