dbus: honor the shutdown timeout in the reboot family

initctl -t N reboot arms an emergency bypass timer over the legacy
socket, but the bus methods took no argument, so the timeout was
silently dropped whenever D-Bus was up.

Reboot, Halt, and Poweroff now take a timeout in seconds, 0 for
none, armed via the same shutdown_bypass() the legacy path uses.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-08-16 22:03:38 +02:00
1 parent 8b61aaea1a
commit 62b55d5b43
6 files changed
+55 -24

No files matched your search

+23
View File
@@ -94,6 +94,29 @@ static void shutdown_wdt_cb(uev_t *w, void *arg, int events)
do_shutdown(halt);
}
/*
* Emergency shutdown bypass, same job as the shutdown watchdog above
* but armed by the user: `initctl -t SEC reboot`, on either transport.
*/
static void bypass_shutdown(void *unused)
{
(void)unused;
cprintf("TIMEOUT TIMEOUT SHUTTING DOWN NOW!!\n");
do_shutdown(halt);
}
static struct wq emergency = { .cb = bypass_shutdown };
void shutdown_bypass(int timeout)
{
if (timeout <= 0)
return;
emergency.delay = timeout * 1000;
schedule_work(&emergency);
}
/*
* User-requested runlevel change, shared by the legacy API and the
* D-Bus SetRunlevel method. Refused in runlevel 0/6, deferred via