To prevent systemd going idle and going to sleep during build or sync emerge should call `systemd-inhibit --mode=block --what=idle --who=portage --why="emerge running"`. See for example RPM plugin https://www.man7.org/linux/man-pages/man8/rpm-plugin-systemd-inhibit.8.html Reproducible: Always Steps to Reproduce: Set IdleAction and emerge something Actual Results: machines goes "idle" and sleeps Expected Results: machines goes brrrr my config. > 📄 `/etc/systemd/logind.conf` > > ```ini > [Login] > HandlePowerKey=suspend > HandlePowerKeyLongPress=poweroff > HandleHibernateKey=suspend > HandleHibernateKeyLongPress=hibernate > IdleAction=suspend > IdleActionSec=15min > ```
$ grep Idle /etc/systemd/logind.conf #IdleAction=ignore #IdleActionSec=30min #StopIdleSessionSec=infinity It looks like by default, nothing is done on idle? I'm not sure Portage is the right place to change the behavior of users' configuration.
I think you are correct about default behaviour but emerge should allow it to be called somehow. But I think allowing a script to be called by emerge is a security risk? Or am I going to be forced to `alias emerge = systemd-inhibit ... emerge`
(In reply to C. Wijtmans from comment #2) > I think you are correct about default behaviour but emerge should allow it > to be called somehow. But I think allowing a script to be called by emerge > is a security risk? Or am I going to be forced to `alias emerge = > systemd-inhibit ... emerge` I suspect a wrapper script will yield the quickest resolution for you. Emerge has "hooks" that it calls at various points; but the primary function of hooks is to run code at certain times while emerge is running (during hooked points of interest where we run callbacks); hooks are not needed for pre / post actions; callers can simply wrap emerge in those cases. -A
Is there a hook for installation phase? That is the most important one against possible corruptions. Although i would like to have one for the whole process
My first thought was to prevent system to idle when emerge is doing its thing. The thing is i just realized how important inhibiting shutdown or reboot during installation would be bumping the importance of the "bug" report a bit.
(In reply to C. Wijtmans from comment #5) > My first thought was to prevent system to idle when emerge is doing its > thing. The thing is i just realized how important inhibiting shutdown or > reboot during installation would be bumping the importance of the "bug" > report a bit. You've made me realise a good reason to do it as well. We don't want the system to go to sleep or similar during PAM upgrades (think pam upgraded but not pambase yet, or vice versa), because there's a risk of the screenlocker not working when it comes back. That's disruptive in itself but it also might cause the user to reboot (making the situation worse as it'll disrupt the ongoing upgrade).
Forums discussion: https://forums.gentoo.org/viewtopic-t-1163094.html.
Actually my system is about a NAS(headless and no GUI) I am making with old hardware and I do not want it running all the time using 50watt. In suspend it consumes 3watt and waits for a wol mmagic/unicast signal. The issue is systemd uses "user activity" to determine idle, whatever that means. When talking baout default behaviour systemd turns off when you press the power button. That is dangerous to do during an installation process so emerge should inihibt poweroff/reboot at the very least. I configured it to suspend instead. But i think it would be wise to inhibit suspend/sleep/hibernatae as well since a lot can go wrong there. It really doesnt solve my main problem but it solves a problem with emerge and power management(with systemd) considering it even happens with default behaviour in the systemd profile.
Feels like this could use some hooks that can be run at emerge start and finish so you can implement on your system to call systemd-inhibit, others could use caffeinate, etc. If the start hook would expose portage's main PID via an envvar, it would be trivial to call something like caffeinate -w ${MAIN_PID}.