From 4a6f646f50ecac88a4d1523ae6556689a58d045e Mon Sep 17 00:00:00 2001 From: joe Date: Wed, 20 Apr 2011 21:38:27 +0200 Subject: fixed kernel command line reading & fixed performShutDown / performReboot --- src/fbgui.cpp | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'src/fbgui.cpp') diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 2222f74..8d2135a 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -313,14 +313,14 @@ void fbgui::toggleDebugConsole() { * @see JavascriptInterface::shutDown() */ void fbgui::performShutDown() { - QProcess *process = new QProcess(this); - QString cmd("echo o > /proc/sysrq-trigger"); - qxtLog->debug() << "[sysinfo] Script Output: try to open: " << cmd; - process->start(cmd, QIODevice::ReadOnly); - - if (!process->waitForStarted()) - qxtLog->debug() - << "[sysinfo] Script Output: process couldn't get opened"; + QFile file("/proc/sysrq-trigger"); + if (file.open(QIODevice::WriteOnly)) { + file.write("o"); + file.close(); + } + else { + qxtLog->debug() << "[gui] Could not open /proc/sysrq-trigger"; + } } //------------------------------------------------------------------------------------------- /** @@ -336,14 +336,14 @@ void fbgui::performShutDown() { * @see JavascriptInterface::reboot() */ void fbgui::performReboot() { - QProcess *process = new QProcess(this); - QString cmd = "echo b > /proc/sysrq-trigger"; - qxtLog->debug() << "[sysinfo] Script Output: try to open: " << cmd; - process->start(cmd, QIODevice::ReadOnly); - - if (!process->waitForStarted()) - qxtLog->debug() - << "[sysinfo] Script Output: process couldn't get opened"; + QFile file("/proc/sysrq-trigger"); + if (file.open(QIODevice::WriteOnly)) { + file.write("b"); + file.close(); + } + else { + qxtLog->debug() << "[gui] Could not open /proc/sysrq-trigger"; + } } //------------------------------------------------------------------------------------------- /** @@ -376,24 +376,25 @@ void fbgui::prepareKexec() { qxtLog->debug() << "[gui] Complete KCL: " << kcl; - QProcess *process = new QProcess(this); QString cmdline = "kexec -l " + downloadPath.toUtf8() + "/kernel --initrd=" - + downloadPath.toUtf8() + "/initramfs --append=\"" + kcl.toUtf8() + "\""; - qxtLog->debug() << "[gui] kexec cmdline: " << cmdline ; + + downloadPath.toUtf8() + "/initramfs --append=\"" + kcl.toUtf8() + + "\""; + qxtLog->debug() << "[gui] kexec cmdline: " << cmdline; process->start(cmdline); bool ret = process->waitForFinished(); if (!ret) { qxtLog->debug() << "[sysinfo] Failed to load kexec! Exiting..."; - exit(EXIT_FAILURE); - } - else { + exit( EXIT_FAILURE); + } else { qxtLog->debug() << "[gui] Kexec load successfull."; if (debugMode < 0) { runKexec(); } else { - qxtLog->debug() << "[gui] Skipping execution of kexec - open debug shell."; - qxtLog->debug() << "[gui] To start the system execute \"kexec -e\" in your shell."; + qxtLog->debug() + << "[gui] Skipping execution of kexec - open debug shell."; + qxtLog->debug() + << "[gui] To start the system execute \"kexec -e\" in your shell."; close(); } } @@ -403,6 +404,6 @@ void fbgui::runKexec() { process->startDetached("kexec -e"); if (!process->waitForStarted()) { qxtLog->debug() << "[gui] Failed to execute: kexec -e"; - exit(EXIT_FAILURE); + exit( EXIT_FAILURE); } } -- cgit v1.2.3-55-g7522