Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 06 Apr 2015 14:35:30 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-acpi@freebsd.org
Cc:        freebsd-bugs@freebsd.org
Subject:   Re: How to know the system state if the system is going for halt or poweroff or reboot in FreeBSD
Message-ID:  <3069256.iCnUzzNb56@ralph.baldwin.cx>
In-Reply-To: <cbf5dcad395190fc8f9716bbc68b4ec1@mail.gmail.com>
References:  <cbf5dcad395190fc8f9716bbc68b4ec1@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.
>=20
> And I can get the information from the =E2=80=9Chowto=E2=80=9D variab=
le 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 ev=
enthandler
you can get the howto argument that way.  ACPI uses this to power off t=
he machine
for a power off request for example:

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


--=20
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3069256.iCnUzzNb56>