Battling The ACPI Daemon
Recently I caused some of my own grief. The resulting journey led me into the proverbial rabbit hole.
I was updating my systems. When I bulk update all systems I connect my laptop to my LAN using Ethernet rather than wireless. Much faster.
After performing updates on the laptop I launched my backup script. Five minutes later I forgot I was doing the backup. I closed the lid. I left the laptop like this for a couple of hours.
Face palming led to favorite four letter words.
I decided to prevent this from happening again.
I have used my own custom safe-shutdown script to avoid similar heartaches. Linux based systems are unforgiving when the reboot, halt, or poweroff commands are executed. My safe-shutdown script is a wrapper to those commands and only allows those commands to execute when no critical tasks are running.
On a non systemd system this is a straightforward exercise. I edit /etc/inittab
and login managers to invoke the script rather than the base commands. This approach has worked well for me for many years.
Back when I struggled to use my script in systemd, I had updated the script to support sleep and hibernation. I never completed that support. With my recent pain point I was pleased to discover that most of the work was already complete. I had only to tweak the script a little.
Yet my script did not behave in the manner I expected.
My first step into the rabbit hole was discovering typos in the /etc/acpi/acpi_handler.sh
script. As is the normal custom, the script is packaged by the Slackware maintainer without modifications from upstream, which means, not a really useful or robust script. When I had modified the script I introduced some typos. The typos caused the script to fail, which I never noticed.
I then verified or updated all /etc/acpi/events
configurations as well as all respective /etc/acpi/
scripts.
My safe-shutdown script still did not function as I expected.
Everything worked fine when I tested the script manually in a terminal window by launching a defined critical task before executing the safe-shutdown script. Everything worked when I was not in X.
When in X the system immediately suspended and ignored my configurations to launch the safe-shutdown script. This confused me for a few hours. Eventually I surrendered for the day.
As is often the case for me, walking away from the problem helped me find the root cause of the mischief. I use the MATE desktop. The next day I realized the MATE power manager was intercepting my ACPI configurations.
Other than DPMS support for the screen display, I configured all other related power management options to Do nothing
. Thereafter my safe-shutdown script worked as expected.
Because of the additional checks, suspending to sleep now takes a few extra seconds. When I close the lid or press Fn+F4
the crescent moon LED starts flashing. The system does not sleep until the safe-shutdown script completes gracefully and executes the pm-suspend
command. I tad bit more patience is now required to place the laptop to sleep, but not that much more. More importantly, I no longer interrupt critical tasks.
Posted: Usability Tagged: General
Category:Next: Broken Kernels
Previous: Nagios Log Date Stamps