From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 6 19:19:26 2015 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 63CB5ACD; Mon, 6 Apr 2015 19:19:26 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C1A17E6; Mon, 6 Apr 2015 19:19:26 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 25760B95D; Mon, 6 Apr 2015 15:19:25 -0400 (EDT) From: John Baldwin To: freebsd-acpi@freebsd.org Subject: Re: How to know the system state if the system is going for halt or poweroff or reboot in FreeBSD Date: Mon, 06 Apr 2015 14:35:30 -0400 Message-ID: <3069256.iCnUzzNb56@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 06 Apr 2015 15:19:25 -0400 (EDT) Cc: freebsd-bugs@freebsd.org, Sibananda Sahu X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2015 19:19:26 -0000 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