DOSHUTDOWNHOOKS(9)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’… DOSHUTDOWNHOOKS(9) πŸ’…

okay so bestie, welcome to the Kernel Developer's Manual β€” yes, the kernel one, we're going deep today. this page is about doshutdownhooks, the little function that runs all your shutdown hooks. it's a whole vibe, but it's also, like, deprecated, so listen up 🫢


✨ NAME ✨

doshutdownhooks β€” run all shutdown hooks. that's it, that's the whole job. iconic honestly πŸ’…


🌸 SYNOPSIS 🌸

void
doshutdownhooks(void);

no args, no drama. she takes void and she takes names. periodt.


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first things first, and i need you to hear me on this one: the doshutdownhooks routine is deprecated. like, not "old but cute" deprecated β€” actually deprecated. use pmf_system_shutdown(9) instead. that's the move, bestie, that's the main character now πŸ‘‘

the doshutdownhooks() function invokes all the shutdown hooks that were established using the shutdownhook_establish(9) function. all of them. every single one. no cap.

and here's the fun part: shutdown hooks are called in reverse order β€” i.e., the shutdown hook established last will be called first. it's giving stack energy, it's giving LIFO, it's giving "last one in, first one out" πŸ’…βœ¨

this function is called from cpu_reboot() with interrupts turned off 🚨. and when does it get called, exactly? okay so picture this β€” it's called immediately before the system is halted or rebooted, and the sequence is very specific:

  • after file systems have been unmounted
  • after the clock has been updated
  • after a system dump has been done (if necessary)

so yeah, she shows up at the very end of the party, after all the cleanup, right before the lights go out. 🌈

ngl bestie, "interrupts turned off" is not a drill β€” this is the last-call zone, things are serious here 😭

πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page, bestie!! πŸ’– this one came from Debian, dated February 11, 2010, and it was published in the DOSHUTDOWNHOOKS(9) section of the Kernel Developer's Manual β€” so go forth, use pmf_system_shutdown(9) instead, and slay πŸ¦‹β­πŸŽ€

πŸ“¦ where this page comes from