:: Re: [devuan-dev] [PATCH] runit: s…
Top Page
Delete this message
Reply to this message
Author: lorenzo
Date:  
To: enricopitea
CC: devuan developers internal list
Subject: Re: [devuan-dev] [PATCH] runit: shutdown -h / poweroff does not cut the power — execv bypasses syscall_shutdown fallback
Hello Enrico,

thanks for your time and interest in runit

On Thu, 30 Jul 2026 14:00:58 +0200 (CEST)
enricopitea@??? wrote:

> Hello Devuan developers,
>
> I found a bug in runit's shutdown binary (debian/contrib/shutdown.c)
> that affects Devuan systems using runit as PID 1.
>
> == Symptom ==
>
> On Devuan Ceres with runit, `shutdown -h now` and `poweroff` leave
> the system in a state where services are stopped (stage 3 completes)
> but the hardware never powers off. The kernel calls RB_HALT instead
> of RB_POWER_OFF.



> == Root Cause ==
>
> In debian/contrib/shutdown.c (package runit 2.3.1-4), the function
> runit_shutdown() at line 144 does:
>
>     char* args[] = {"/usr/sbin/init", "0", NULL};
>     execv("/usr/sbin/init", args);
>
> execv() REPLACES the current process with init. The code that follows
> in main():
>
>     sleep(15);
>     syscall_shutdown(cfg.action);   // calls reboot(RB_POWER_OFF)
>
> is NEVER reached — the process no longer exists.


ok, so far

> PID 1 runs stage 3
> and then halts via RB_HALT, which stops the CPU but does not cut the
> power on modern hardware.


I'm not convinced by the above:
if you look at runit.c (around lines 302-335)
https://salsa.debian.org/debian/runit/-/blob/master/runit-2.3.1/src/runit.c?ref_type=heads
you can see that the order is RB_POWER_OFF --> RB_HALT_SYSTEM -->
RB_HALT
so it falls back to HALT only if the platform does not define
RB_POWER_OFF, which is not your case because syscall_shutdown from
shutdown.c (lines 114-137) uses the very same logic
https://salsa.debian.org/debian/runit/-/blob/master/debian/contrib/shutdown.c?ref_type=heads

I need more info:

> In debian/contrib/shutdown.c (package runit 2.3.1-4), the function


except from rebuilding shutdown.c, are you using the official package
from Devuan/Debian (maybe you rebuilded the runit.deb package for other
reasons?)

> On Devuan Ceres with runit, `shutdown -h now` and `poweroff` leave
> the system in a state where services are stopped (stage 3 completes)
> but the hardware never powers off. The kernel calls RB_HALT instead
> of RB_POWER_OFF.


Do you observe this bug in one or more than one system(s)?
when you have this bug, what are the last two lines that you see printed
on the screen (at the very end of stage 3)? Maybe could you share a
picture on something like pasteboard?

Best,
Lorenzo