From /etc/acpi/actions/powerbtn.sh (note also typo in "managment"): # No power managment system appears to be running. Just initiate a plain # shutdown. CURRENT_INIT=`ps -p 1 -o comm=` if [ "$CURRENT_INIT" = "openrc-init" ] then /sbin/openrc-shutdown -p else /sbin/shutdown -h now "Power button pressed" fi If sys-apps/openrc is installed with USE="sysv-utils" (whereby /sbin/init is a symlink to "openrc-init") and the kernel is booted without an explicit init=/sbin/openrc-init option, then `ps -p 1 -o comm=` outputs "init" instead of "openrc-init". This in turn causes the else-branch in powerbtn.sh to be taken and /sbin/shutdown to be executed. With sys-apps/openrc[sysv-utils] the file /sbin/shutdown is a symlink to the /lib/rc/bin/shutdown script from openrc, and the -h command line option causes the latter to only halt the system and not power it off. This results in machines hanging and not powering off.
And it appears that the "/sbin/openrc-shutdown -p" command line is also missing the last "now" argument.
Pushed a fix upstream to https://sourceforge.net/p/acpid2/code/merge-requests/3/
Thanks for raising this, Jaak. So I see two distinct issues being reported there: * With the shipped powerbtn.sh and openrc[sysv-utils], pressing the power button does not power off the machine. * When you make the script do the openrc-specific handling, the invocation `/sbin/openrc-shutdown -p` is invalid because it misses the mandatory "when" argument. The second one has been patched upstream by Jonathan Davies (huge thanks!). There's no release from the upstream yet, but that's not a blocker as we can apply a patch at Gentoo level. The first one is not resolved yet. I am suspicious that the issue is not that acpid fails to recognize openrc, because openrc mimics System V init system in this case, so System V init system interfaces documentation define how things must work. According to shutdown(8) man page from sys-apps/sysvinit, `/sbin/shutdown -h ...` means "Equivalent to -P, unless -H is specified". And the option `-P` means "Action is to turn off the power". So acpid invokes a command which means powering off. So if openrc-provided shutdown tool doesn't power off the machine, it's the fault of openrc-provided shutdown tool. So I think this is an interface adherence issue for openrc. I guess the issue is in this file: https://github.com/OpenRC/openrc/blob/master/scripts/shutdown.in Could you confirm the following, Jaak? * Commands "/sbin/shutdown -P", "/lib/rc/bin/shutdown -P" do turn off the power. * /lib/rc/bin/shutdown file installed on your system resembles the shutdown.in script I linked above. * Manually editing "h) shutdown_arg=--halt ;;" to "h) shutdown_arg=--poweroff ;;" makes power button press to power off your machine. Once my hypothesis is confirmed, we will bring it (with a trivial patch I guess) to openrc folks.
(In reply to Andrey Utkin from comment #3) > Could you confirm the following, Jaak? > > * Commands "/sbin/shutdown -P", "/lib/rc/bin/shutdown -P" do turn off the > power. Both "/sbin/shutdown -P" and "/lib/rc/bin/shutdown -P" do NOT turn off the power, but error with the output /sbin/openrc-shutdown --poweroff * openrc-shutdown: No shutdown time specified followed by the usage information of openrc-shutdown. Note that /sbin/shutdown is symlinked to /lib/rc/bin/shutdown (probably by openrc[sysv-utils]). > * /lib/rc/bin/shutdown file installed on your system resembles the > shutdown.in script I linked above. I confirm this. The /lib/rc/bin/shutdown file seems to be an the shutdown.in script with @SBINDIR@ expanded. > * Manually editing "h) shutdown_arg=--halt ;;" to "h) > shutdown_arg=--poweroff ;;" makes power button press to power off your > machine. No it doesn't. Instead, nothing happens, except this in the logs: Nov 10 09:18:44 my_vm /etc/init.d/acpid[1664]: openrc-shutdown: No shutdown time specified Nov 10 09:18:45 my_vm /etc/init.d/acpid[1674]: openrc-shutdown: No shutdown time specified
Oh. I forgot about the "when" argument. Could you confirm the following? * Commands "/sbin/shutdown -P now", "/lib/rc/bin/shutdown -P now" do turn off the power. * Power button press powers off your machine once you do both of the following. ** You patch the /etc/acpi/actions/powerbtn.sh as needed to insert the "now" arg. ** Manually edit "h) shutdown_arg=--halt ;;" to "h) shutdown_arg=--poweroff ;;"
(In reply to Andrey Utkin from comment #5) > Could you confirm the following? > > * Commands "/sbin/shutdown -P now", "/lib/rc/bin/shutdown -P now" do turn > off the power. I can confirm this. > * Power button press powers off your machine once you do both of the > following. > ** You patch the /etc/acpi/actions/powerbtn.sh as needed to insert the "now" > arg. > ** Manually edit "h) shutdown_arg=--halt ;;" to "h) shutdown_arg=--poweroff > ;;" I can confirm this as well.
Reported for openrc https://bugs.gentoo.org/755422 .
openrc has got a commit by williamh addressing this issue: https://github.com/OpenRC/openrc/commit/38aaba28ee86602e29d8a31f155dfa72f5481e68 It doesn't seem that openrc does releases often nowadays, though. openrc-9999 should get you the fix, but I won't recommend doing this :) But you could apply this patch to your stable openrc locally :)
Still awaiting OpenRC release. I've got some words from WilliamH on IRC that he does intend to make a release soon.
OpenRC 0.43 is out with the fix. Jaak, with OpenRC 0.43 or later, you should be able to enjoy stuff working without any patches to any of the relevant packages. Please let us know here if the issue persists.