From 343f64f6b8e87dadc4106e41d286f5eaa1e24d5f Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Tue, 5 Jan 2021 23:40:41 +0100 Subject: [PATCH] Restore stored PID in /var/run/funkey.pid --- RetroFE/Source/Execute/Launcher.cpp | 27 +++++++++++---------------- RetroFE/Source/Utility/Utils.h | 1 + 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/RetroFE/Source/Execute/Launcher.cpp b/RetroFE/Source/Execute/Launcher.cpp index 86abf24..6c8d203 100755 --- a/RetroFE/Source/Execute/Launcher.cpp +++ b/RetroFE/Source/Execute/Launcher.cpp @@ -22,6 +22,8 @@ #include "../RetroFE.h" #include "../SDL.h" #include +#include +#include #include #include #include @@ -44,6 +46,7 @@ bool Launcher::run(std::string collection, Item *collectionItem) std::string extensionstr; std::string matchedExtension; std::string args; + bool res = true; std::string launcherFile = Utils::combinePath( Configuration::absolutePath, "collections", collectionItem->collectionInfo->name, "launchers", collectionItem->name + ".conf" ); std::ifstream launcherStream( launcherFile.c_str( ) ); @@ -119,23 +122,15 @@ bool Launcher::run(std::string collection, Item *collectionItem) if(!execute(executablePath, args, currentDirectory)) { Logger::write(Logger::ZONE_ERROR, "Launcher", "Failed to launch."); - - /// Clean VT - int current_VT = Utils::getVTid(); - if(current_VT >= 0){ - printf("ERROR Cleaning VT %d\n", current_VT); - Utils::termfix(current_VT); - } - else{ - for(int i=0; i<=12; i++){ - Utils::termfix(i); - } - } - - return false; + res = false; } - /// Clean VT + /* Restore stored PID */ + char shellCmd[20]; + sprintf(shellCmd, "%s %d", SHELL_CMD_RECORD_PID, getpid()); + Utils::executeRawPath((const char*)shellCmd); + + /* Clean VT */ int current_VT = Utils::getVTid(); if(current_VT >= 0){ printf("Cleaning VT %d\n", current_VT); @@ -147,7 +142,7 @@ bool Launcher::run(std::string collection, Item *collectionItem) } } - return true; + return res; } std::string Launcher::replaceVariables(std::string str, diff --git a/RetroFE/Source/Utility/Utils.h b/RetroFE/Source/Utility/Utils.h index 80aae56..68a1c86 100755 --- a/RetroFE/Source/Utility/Utils.h +++ b/RetroFE/Source/Utility/Utils.h @@ -22,6 +22,7 @@ #define SHELL_CMD_ROOTFS_RW "rw" #define SHELL_CMD_ROOTFS_RO "ro" +#define SHELL_CMD_RECORD_PID "record_pid" class Utils {