Skip to content

Commit 343f64f

Browse files
committed
Restore stored PID in /var/run/funkey.pid
1 parent 63180b9 commit 343f64f

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

RetroFE/Source/Execute/Launcher.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "../RetroFE.h"
2323
#include "../SDL.h"
2424
#include <cstdlib>
25+
#include <sys/types.h>
26+
#include <unistd.h>
2527
#include <locale>
2628
#include <sstream>
2729
#include <fstream>
@@ -44,6 +46,7 @@ bool Launcher::run(std::string collection, Item *collectionItem)
4446
std::string extensionstr;
4547
std::string matchedExtension;
4648
std::string args;
49+
bool res = true;
4750

4851
std::string launcherFile = Utils::combinePath( Configuration::absolutePath, "collections", collectionItem->collectionInfo->name, "launchers", collectionItem->name + ".conf" );
4952
std::ifstream launcherStream( launcherFile.c_str( ) );
@@ -119,23 +122,15 @@ bool Launcher::run(std::string collection, Item *collectionItem)
119122
if(!execute(executablePath, args, currentDirectory))
120123
{
121124
Logger::write(Logger::ZONE_ERROR, "Launcher", "Failed to launch.");
122-
123-
/// Clean VT
124-
int current_VT = Utils::getVTid();
125-
if(current_VT >= 0){
126-
printf("ERROR Cleaning VT %d\n", current_VT);
127-
Utils::termfix(current_VT);
128-
}
129-
else{
130-
for(int i=0; i<=12; i++){
131-
Utils::termfix(i);
132-
}
133-
}
134-
135-
return false;
125+
res = false;
136126
}
137127

138-
/// Clean VT
128+
/* Restore stored PID */
129+
char shellCmd[20];
130+
sprintf(shellCmd, "%s %d", SHELL_CMD_RECORD_PID, getpid());
131+
Utils::executeRawPath((const char*)shellCmd);
132+
133+
/* Clean VT */
139134
int current_VT = Utils::getVTid();
140135
if(current_VT >= 0){
141136
printf("Cleaning VT %d\n", current_VT);
@@ -147,7 +142,7 @@ bool Launcher::run(std::string collection, Item *collectionItem)
147142
}
148143
}
149144

150-
return true;
145+
return res;
151146
}
152147

153148
std::string Launcher::replaceVariables(std::string str,

RetroFE/Source/Utility/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#define SHELL_CMD_ROOTFS_RW "rw"
2424
#define SHELL_CMD_ROOTFS_RO "ro"
25+
#define SHELL_CMD_RECORD_PID "record_pid"
2526

2627
class Utils
2728
{

0 commit comments

Comments
 (0)