How to know the system state if the system is going for halt or poweroff or reboot in FreeBSD

John Baldwin jhb at freebsd.org
Mon Apr 6 19:19:26 UTC 2015


On Thursday, March 26, 2015 01:54:45 AM Sibananda Sahu wrote:
> My requirement is to know the exact reason of shutdown, whether is it a
> power-off or a reboot call.
> 
> And I can get the information from the “howto” variable that is passed to
> the kern_reboot() function call, but this variable is local to
> kern_reboot() only.

It is passed to the shutdown_* eventhandlers.  So if you register an eventhandler
you can get the howto argument that way.  ACPI uses this to power off the machine
for a power off request for example:

static void
acpi_shutdown_final(void *arg, int howto)
{
    ...
    if ((howto & RB_POWEROFF) != 0) {
	status = AcpiEnterSleepStatePrep(ACPI_STATE_S5);
}


-- 
John Baldwin


More information about the freebsd-bugs mailing list