add missing pclose()

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2021-04-13 23:17:34 +02:00
parent 473e9515ec
commit 152bae7693
3 changed files with 36 additions and 6 deletions

View File

@ -47,6 +47,7 @@ bool Launcher::run(std::string collection, Item *collectionItem)
std::string matchedExtension;
std::string args;
bool res = true;
FILE *fp;
std::string launcherFile = Utils::combinePath( Configuration::absolutePath, "collections", collectionItem->collectionInfo->name, "launchers", collectionItem->name + ".conf" );
std::ifstream launcherStream( launcherFile.c_str( ) );
@ -120,7 +121,10 @@ bool Launcher::run(std::string collection, Item *collectionItem)
collection);
/* Restart audio amp */
popen(SHELL_CMD_TURN_AMPLI_ON, "r");
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
if (fp != NULL) {
pclose(fp);
}
/* Execute game */
if(!execute(executablePath, args, currentDirectory))
@ -130,7 +134,10 @@ bool Launcher::run(std::string collection, Item *collectionItem)
}
/* Stop audio amp */
popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
if (fp != NULL) {
pclose(fp);
}
/* Restore stored PID */
char shellCmd[20];

View File

@ -399,6 +399,7 @@ void MenuMode::init_menu_system_values(){
volume_percentage = 50; ///wrong value: setting default to 50
}
else{
pclose(fp);
fgets(res, sizeof(res)-1, fp);
/// Check if Volume is a number (at least the first char)
@ -419,6 +420,7 @@ void MenuMode::init_menu_system_values(){
brightness_percentage = 50; ///wrong value: setting default to 50
}
else{
pclose(fp);
fgets(res, sizeof(res)-1, fp);
/// Check if brightness is a number (at least the first char)
@ -846,6 +848,8 @@ int MenuMode::launch( )
fp = popen(shell_cmd, "r");
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------
@ -862,6 +866,8 @@ int MenuMode::launch( )
fp = popen(shell_cmd, "r");
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------
screen_refresh = 1;
@ -907,6 +913,8 @@ int MenuMode::launch( )
fp = popen(shell_cmd, "r");
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------
screen_refresh = 1;
@ -922,6 +930,8 @@ int MenuMode::launch( )
fp = popen(shell_cmd, "r");
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------
screen_refresh = 1;
@ -1001,6 +1011,7 @@ int MenuMode::launch( )
}
else{
usb_sharing = !usb_sharing;
pclose(fp);
}*/
bool res = Utils::executeRawPath(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);
@ -1091,6 +1102,8 @@ int MenuMode::launch( )
fp = popen(shell_cmd, "r");
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
return MENU_RETURN_EXIT;

View File

@ -48,11 +48,16 @@ Sound::~Sound()
void Sound::play()
{
FILE *fp;
//printf("%s\n", __func__);
SDL_RemoveTimer(idTimer);
if(!ampliStarted){
popen(SHELL_CMD_TURN_AMPLI_ON, "r");
ampliStarted = 1;
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
if (fp != NULL) {
ampliStarted = 1;
pclose(fp);
}
}
if(chunk_)
@ -64,9 +69,14 @@ void Sound::play()
uint32_t Sound::turnOffAmpli(uint32_t interval, void *param)
{
FILE *fp;
//printf("%s\n", __func__);
popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
ampliStarted = 0;
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
if (fp != NULL) {
ampliStarted = 0;
pclose(fp);
}
return 0;
}