Restore stored PID in /var/run/funkey.pid

This commit is contained in:
Vincent-FK 2021-01-05 23:40:41 +01:00
parent 63180b99a7
commit 343f64f6b8
2 changed files with 12 additions and 16 deletions

View File

@ -22,6 +22,8 @@
#include "../RetroFE.h" #include "../RetroFE.h"
#include "../SDL.h" #include "../SDL.h"
#include <cstdlib> #include <cstdlib>
#include <sys/types.h>
#include <unistd.h>
#include <locale> #include <locale>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
@ -44,6 +46,7 @@ bool Launcher::run(std::string collection, Item *collectionItem)
std::string extensionstr; std::string extensionstr;
std::string matchedExtension; std::string matchedExtension;
std::string args; std::string args;
bool res = true;
std::string launcherFile = Utils::combinePath( Configuration::absolutePath, "collections", collectionItem->collectionInfo->name, "launchers", collectionItem->name + ".conf" ); std::string launcherFile = Utils::combinePath( Configuration::absolutePath, "collections", collectionItem->collectionInfo->name, "launchers", collectionItem->name + ".conf" );
std::ifstream launcherStream( launcherFile.c_str( ) ); std::ifstream launcherStream( launcherFile.c_str( ) );
@ -119,23 +122,15 @@ bool Launcher::run(std::string collection, Item *collectionItem)
if(!execute(executablePath, args, currentDirectory)) if(!execute(executablePath, args, currentDirectory))
{ {
Logger::write(Logger::ZONE_ERROR, "Launcher", "Failed to launch."); Logger::write(Logger::ZONE_ERROR, "Launcher", "Failed to launch.");
res = false;
/// 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; /* Restore stored PID */
} char shellCmd[20];
sprintf(shellCmd, "%s %d", SHELL_CMD_RECORD_PID, getpid());
Utils::executeRawPath((const char*)shellCmd);
/// Clean VT /* Clean VT */
int current_VT = Utils::getVTid(); int current_VT = Utils::getVTid();
if(current_VT >= 0){ if(current_VT >= 0){
printf("Cleaning VT %d\n", current_VT); 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, std::string Launcher::replaceVariables(std::string str,

View File

@ -22,6 +22,7 @@
#define SHELL_CMD_ROOTFS_RW "rw" #define SHELL_CMD_ROOTFS_RW "rw"
#define SHELL_CMD_ROOTFS_RO "ro" #define SHELL_CMD_ROOTFS_RO "ro"
#define SHELL_CMD_RECORD_PID "record_pid"
class Utils class Utils
{ {