From e2580d77cf118ee01e23c8606162a71756486bab Mon Sep 17 00:00:00 2001 From: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Wed, 22 Dec 2021 09:21:07 +0100 Subject: [PATCH] Feature shutdown improvement (#556) * Use init instead of reboot for shutdown and restart * Include file update --- src/raspberrypi/rascsi.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index 2bf3df79..a0477843 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -28,8 +28,6 @@ #include "rascsi_interface.pb.h" #include "spdlog/spdlog.h" #include "spdlog/sinks/stdout_color_sinks.h" -#include -#include #include #include #include @@ -1162,9 +1160,8 @@ void ShutDown(int fd, const string& mode) { SerializeMessage(fd, result); DetachAll(); - sync(); - if (reboot(LINUX_REBOOT_CMD_HALT) == -1) { + if (system("init 0") == -1) { LOGERROR("System shutdown failed: %s", strerror(errno)); } } @@ -1174,9 +1171,8 @@ void ShutDown(int fd, const string& mode) { SerializeMessage(fd, result); DetachAll(); - sync(); - if (reboot(LINUX_REBOOT_CMD_RESTART) == -1) { + if (system("init 6") == -1) { LOGERROR("System reboot failed: %s", strerror(errno)); } }