CPU_REBOOT(9)
π CPU_REBOOT(9) β the kernel developer's manual, but make it make sense π
okay bestie, so this page is CPU_REBOOT(9) from the Kernel Developer's Manual β section 9, kernel-adjacent, very "final boss of the boot sequence" energy. It's the function that literally hits the lights or restarts the whole vibe. Let's get into it π«Ά
β¨ NAME β¨
cpu_reboot β halt or reboot the system. that's it. that's the whole job. the end-of-day function. the "we're closing, please make your way to the exit" of kernel space π
π SYNOPSIS π
#include <sys/reboot.h>
void
cpu_reboot(int howto, char *bootstr);
so it takes an int howto and a char *bootstr, and it returns void β meaning it does not give you anything back. it's giving "I am the last thing that happens, there is no return, there is no after." main character energy fr fr π
πΈ DESCRIPTION πΈ
The cpu_reboot() function handles the final system shutdown, and then either halts or reboots the system. Which one it picks depends on two things, no cap:
- the flags you pass in
howto - whether or not the system has finished autoconfiguration
Two whole paths. Two whole vibes. Let's go.
π₯ if the system HAS finished autoconfiguration
then cpu_reboot() does the following, in this exact order (the order matters, do not shuffle, this is not a playlist):
- Sets the
boothowtosystem variable (seeboothowto(9)) from thehowtoargument. lowkey just recording what you asked for, so the next boot knows the lore π - If this is the first invocation of
cpu_reboot()and theRB_NOSYNCflag is not set inhowto, it syncs and unmounts the system disks by callingvfs_shutdown(9), and sets the time of day clock by callingresettodr(9). this is the "save your work before I close the laptop" step and it is so important π - Disables interrupts. everyone quiet, the adults are talking π€«
- If rebooting after a crash (i.e., if
RB_DUMPis set inhowto, butRB_HALTis not), it saves a system crash dump. yes bestie, we're preserving the evidence π - Runs any shutdown hooks by calling
pmf_system_shutdown(9). hooks get to say their goodbyes π₯Ή - Prints a message indicating that the system is about to be halted or rebooted. a little announcement, a little "going down in 3, 2, 1" π’
- If
RB_HALTis set inhowto, it halts the system. Otherwise, it reboots the system. that's the fork in the road, the whole plot twist, the moment β¨
π if the system has NOT finished autoconfiguration
then it's a whole different situation, and honestly it's simpler: cpu_reboot() runs any shutdown hooks by calling pmf_system_shutdown(9), prints a message, and halts the system.
that's it. no disk sync step listed here, no dump step listed here β the page only says hooks, message, halt. don't go adding steps that aren't in the original, i'm watching you π
π¦ one more thing: bootstr
If RB_STRING is set in howto, then the parameter bootstr is passed to the system boot loader on some ports. not all ports! some. iykyk π§
π SEE ALSO π
the whole friend group, assembled:
boothowto(9)dumpsys(9)pmf_system_shutdown(9)resettodr(9)vfs_shutdown(9)
π sign-off π
that's the whole page, bestie β go forth and reboot responsibly π this little icon was brought to you by Debian, dated February 11, 2010, from the CPU_REBOOT(9) page in the Kernel Developer's Manual. periodt π
π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 1994 Christopher G. Demetriou
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms