DOHOOKS(9)

πŸ“¦ in nixpkgs unstable

✨ DOHOOKS(9) from the Kernel Developer’s Manual β€” run all hooks, bestie ✨

πŸŽ€ NAME πŸŽ€

dohooks β€” run all hooks in a list πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <sys/types.h>
#include <sys/systm.h>

void
dohooks(struct hook_desc_head *head, int flags);

πŸ’– DESCRIPTION πŸ’–

Okay so the dohooks() function literally invokes all the hooks established using the hook_establish(9) function. No cap. 🫢

Hooks get called in the order of the TAILQ that head points to. But plot twist: hook_establish(9) can put the hooks either at the head or the tail of that queue, which makes it possible to call the hooks either in the order of establishment or its reverse. Iconic queue behavior, honestly. πŸ”₯

The flags can specify:

  • HOOK_REMOVE β€” remove already processed hooks from the hook list 🧹
  • HOOK_FREE β€” also free them 🧚
Lowkey important: in most cases you want either no flags at all, or HOOK_REMOVE and HOOK_FREE at the same time. Just HOOK_REMOVE will drop the only reference to allocated memory, so it should only be used in situations where freeing memory would be illegal and unnecessary. That’s the rule, bestie β€” do not play with it. πŸ˜­πŸ’€

This function is used to implement the dostartuphooks(9) macro. Slay. ✨

πŸ’… SEE ALSO πŸ’…

Later, bestie πŸ’– β€” this page is from Debian, dated December 12, 2015, and it’s literally DOHOOKS(9). Mwah! πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from