diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-01-27 17:44:18 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-01-27 17:44:18 +0100 |
commit | 4a8a2b2d662f5de300d789d31078b9d75e94106a (patch) | |
tree | a401c4cf419e9f34fd10d5acbf234f44b51088d8 | |
parent | d67388e986f1724b804d602040b82715116f3f7d (diff) | |
download | rvnit-4a8a2b2d662f5de300d789d31078b9d75e94106a.tar.gz rvnit-4a8a2b2d662f5de300d789d31078b9d75e94106a.tar.xz rvnit-4a8a2b2d662f5de300d789d31078b9d75e94106a.zip |
linux: shutdown/reboot when pid 1
-rw-r--r-- | rvnit.c | 14 |
1 files changed, 14 insertions, 0 deletions
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; } |