use system() rather than popen() in FunKey menu

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2021-04-27 23:07:29 +02:00
parent 9a9989d6ac
commit 67e0f34b93

View File

@ -717,7 +717,6 @@ int MenuMode::launch( )
int start_scroll=0; int start_scroll=0;
uint8_t screen_refresh = 1; uint8_t screen_refresh = 1;
char shell_cmd[100]; char shell_cmd[100];
FILE *fp;
uint8_t menu_confirmation = 0; uint8_t menu_confirmation = 0;
stop_menu_loop = 0; stop_menu_loop = 0;
char fname[MAXPATHLEN]; char fname[MAXPATHLEN];
@ -845,12 +844,7 @@ int MenuMode::launch( )
/// ----- Shell cmd ---- /// ----- Shell cmd ----
sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage); sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
fp = popen(shell_cmd, "r"); system(shell_cmd);
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------ /// ------ Refresh screen ------
screen_refresh = 1; screen_refresh = 1;
@ -863,12 +857,8 @@ int MenuMode::launch( )
/// ----- Shell cmd ---- /// ----- Shell cmd ----
sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage); sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
fp = popen(shell_cmd, "r"); system(shell_cmd);
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------ /// ------ Refresh screen ------
screen_refresh = 1; screen_refresh = 1;
} }
@ -910,12 +900,8 @@ int MenuMode::launch( )
/// ----- Shell cmd ---- /// ----- Shell cmd ----
sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage); sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
fp = popen(shell_cmd, "r"); system(shell_cmd);
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------ /// ------ Refresh screen ------
screen_refresh = 1; screen_refresh = 1;
} }
@ -927,12 +913,8 @@ int MenuMode::launch( )
/// ----- Shell cmd ---- /// ----- Shell cmd ----
sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage); sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
fp = popen(shell_cmd, "r"); system(shell_cmd);
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
/// ------ Refresh screen ------ /// ------ Refresh screen ------
screen_refresh = 1; screen_refresh = 1;
} }
@ -1005,14 +987,7 @@ int MenuMode::launch( )
menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1); menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1);
/// ----- Shell cmd ---- /// ----- Shell cmd ----
/*fp = popen(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT, "r"); /*system(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);*/
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
}
else{
usb_sharing = !usb_sharing;
pclose(fp);
}*/
bool res = Utils::executeRawPath(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT); bool res = Utils::executeRawPath(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);
if (!res) { if (!res) {
@ -1099,13 +1074,7 @@ int MenuMode::launch( )
/// ----- Shell cmd ---- /// ----- Shell cmd ----
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN); sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
fp = popen(shell_cmd, "r"); system(shell_cmd);
if (fp == NULL) {
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
} else {
pclose(fp);
}
return MENU_RETURN_EXIT; return MENU_RETURN_EXIT;
} }
else{ else{