Date: Wed, 23 Sep 2015 01:28:47 -0700 From: Colin Percival <cperciva@freebsd.org> To: Jung-uk Kim <jkim@FreeBSD.org>, Anthony Jenkins <Scoobi_doo@yahoo.com>, "freebsd-acpi@freebsd.org" <freebsd-acpi@freebsd.org> Subject: Re: disabling sleep when shutting down Message-ID: <560262BF.7090107@freebsd.org> In-Reply-To: <5601A863.5070406@FreeBSD.org> References: <55FA3848.7090802@freebsd.org> <55FB233D.2080000@FreeBSD.org> <55FB48E3.20401@freebsd.org> <55FC4F13.3090603@FreeBSD.org> <55FC57F9.3050702@yahoo.com> <55FE5D54.1030806@freebsd.org> <5601A863.5070406@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 09/22/15 12:13, Jung-uk Kim wrote:
>> I didn't want to pollute init with arch-dependent hacks. Anyway,
>> the attached patch should do what you want (not tested).
>
> Or a simpler hack with sysctl(3) instead of ioctl(2).
Right, this is more like what I was thinking. (I can write patches myself
btw -- I was asking for help with figuring out the right solution, not with
the coding itself!)
A couple things I'm not sure about though:
> + /* Temporarily block any suspend requests. */
> + len = sizeof(blocked);
> + block = 1;
> + if (sysctlbyname("debug.acpi.sleep_blocked", &blocked, &len,
> + &block, sizeof(block)) == -1)
> + blocked = 0;
Wouldn't it make sense to wrap this in "if (Reboot)"? That way it would block
suspend for poweroff / halt / reboot, but not for dropping to single-user
mode.
> +#if defined(__amd64__) || defined(__i386__)
> + /* Unblock suspend requests. */
> + if (!blocked)
> + sysctlbyname("debug.acpi.sleep_blocked", NULL, NULL,
> + &blocked, sizeof(blocked));
> +#endif
> +
And if we restrict the blocking to only happen if (Reboot), is there any point
unblocking suspend when we're about to call reboot(2)?
--
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?560262BF.7090107>
