From 4a8a2b2d662f5de300d789d31078b9d75e94106a Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Thu, 27 Jan 2022 17:44:18 +0100 Subject: linux: shutdown/reboot when pid 1 --- rvnit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rvnit.c b/rvnit.c index f49fdd3..ed6abd2 100644 --- a/rvnit.c +++ b/rvnit.c @@ -1050,4 +1050,18 @@ cont4: close(selflogfd[1]); pthread_join(logger_thread, 0); + +#ifdef __linux__ + if (pid1) { + sync(); + if (want_reboot) { + reboot(RB_AUTOBOOT); + } else { + // falls back to RB_HALT_SYSTEM if not possible + reboot(RB_POWER_OFF); + } + } +#endif + + return 0; } -- cgit 1.4.1