Use pure Go unix.Reboot function in rc.init

Use unix.Reboot from golang.org/x/sys/unix for poweroff and reboot
instead of relying on external commands.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
This commit is contained in:
Tobias Klauser 2018-01-04 10:28:23 +01:00
parent c84b6ea474
commit 642c6f23ac

View File

@ -411,13 +411,9 @@ func doShutdown(action string) {
unmountAll()
switch action {
case "poweroff":
// TODO use syscall
cmd := exec.Command("/sbin/poweroff", "-f")
_ = cmd.Run()
_ = unix.Reboot(unix.LINUX_REBOOT_CMD_POWER_OFF)
case "reboot":
// TODO use syscall
cmd := exec.Command("/sbin/reboot", "-f")
_ = cmd.Run()
_ = unix.Reboot(unix.LINUX_REBOOT_CMD_RESTART)
}
// if this failed, init will try again
os.Exit(0)