disabling sleep when shutting down
Colin Percival
cperciva at freebsd.org
Tue Sep 22 08:26:38 UTC 2015
On 09/20/15 03:04, Ian Smith wrote:
> On Sun, 20 Sep 2015 00:16:36 -0700, Colin Percival wrote:
> > On 09/18/15 11:29, Anthony Jenkins wrote:
> > > Is it possible for /etc/rc.shutdown to complete, but shutdown not
> > > occur? If so, there should be a mechanism to restore the ability to
> > > suspend. Other than that, I like it.
> >
> > Hmm... well, rc.shutdown runs before the system drops into single-user
> > mode. Which makes me think that maybe we should be making the kernel
> > call from inside init instead of from rc.shutdown.
>
> I still think disabling suspend from shutdown.c, at the same time as
> creating /var/run/nologin might be the best way to go, to avoid any
> possibility of untimely suspending once committed to shutting down.
So you think we should disable suspend for the last 5 minutes before a
scheduled shutdown? This seems a bit strange to me... and I honestly can't
imagine a situation where you'd need to announce an imminent shutdown of
your laptop to logged-in users.
> For one thing, shutdown's -o flag bypasses using init and calls halt or
> reboot directly, though I don't know if anyone uses that.
Right, I figured it wasn't worth worrying about that case since anyone who
uses that hopefully knows what they're doing; also since that skips running
rc.shutdown there's a much smaller race window.
On the other hand, "send a signal to init" and the sysv compatible approach
of running `init [runlevel]` are likely to be used by other tools (e.g.,
desktop environments), so I don't think we should assume that reboot/poweroff
requests always go through shutdown(8).
> For another,
> if shutdown fails for any reason, or is cancelled by signal by the user
> .. or in any case, I gather .. finish() removes /var/run/nologin, and
> could also there reenable suspend, covering Anthony's point.
This would also be accomplished by having the suspend-disabling done by init;
if you tell shutdown(8) to not shut the system down, then it never sends the
relevant signal to init. The shutdown(8) utility doesn't do any shutting
down itself; it's just a front-end which makes an announcement, sets a timer,
and disables logins, and then ultimately asks init(8) to do the real work
(including spawning rc.shutdown).
--
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
More information about the freebsd-acpi
mailing list