@@ -397,6 +397,7 @@ void init_menu_system_values(){
397397 volume_percentage = 50 ; // /wrong value: setting default to 50
398398 }
399399 else {
400+ pclose (fp);
400401 fgets (res, sizeof (res)-1 , fp);
401402
402403 // / Check if Volume is a number (at least the first char)
@@ -417,6 +418,7 @@ void init_menu_system_values(){
417418 brightness_percentage = 50 ; // /wrong value: setting default to 50
418419 }
419420 else {
421+ pclose (fp);
420422 fgets (res, sizeof (res)-1 , fp);
421423
422424 // / Check if brightness is a number (at least the first char)
@@ -659,7 +661,10 @@ void run_menu_loop()
659661 RES_HW_SCREEN_HORIZONTAL * RES_HW_SCREEN_VERTICAL * sizeof (u16 ));
660662
661663 /* Stop Ampli */
662- popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
664+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
665+ if (fp != NULL ) {
666+ pclose (fp);
667+ }
663668
664669 // / -------- Main loop ---------
665670 while (!stop_menu_loop)
@@ -737,7 +742,9 @@ void run_menu_loop()
737742 fp = popen (shell_cmd, " r" );
738743 if (fp == NULL ) {
739744 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
740- }
745+ } else {
746+ pclose (fp);
747+ }
741748
742749 // / ------ Refresh screen ------
743750 screen_refresh = 1 ;
@@ -753,6 +760,8 @@ void run_menu_loop()
753760 fp = popen (shell_cmd, " r" );
754761 if (fp == NULL ) {
755762 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
763+ } else {
764+ pclose (fp);
756765 }
757766 // / ------ Refresh screen ------
758767 screen_refresh = 1 ;
@@ -809,6 +818,8 @@ void run_menu_loop()
809818 fp = popen (shell_cmd, " r" );
810819 if (fp == NULL ) {
811820 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
821+ } else {
822+ pclose (fp);
812823 }
813824 // / ------ Refresh screen ------
814825 screen_refresh = 1 ;
@@ -824,6 +835,8 @@ void run_menu_loop()
824835 fp = popen (shell_cmd, " r" );
825836 if (fp == NULL ) {
826837 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
838+ } else {
839+ pclose (fp);
827840 }
828841 // / ------ Refresh screen ------
829842 screen_refresh = 1 ;
@@ -885,6 +898,8 @@ void run_menu_loop()
885898 fp = popen (shell_cmd, " r" );
886899 if (fp == NULL ) {
887900 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
901+ } else {
902+ pclose (fp);
888903 }
889904
890905 stop_menu_loop = 1 ;
@@ -922,6 +937,8 @@ void run_menu_loop()
922937 fp = popen (shell_cmd, " r" );
923938 if (fp == NULL ) {
924939 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
940+ } else {
941+ pclose (fp);
925942 }
926943
927944 stop_menu_loop = 1 ;
@@ -1019,7 +1036,10 @@ void run_menu_loop()
10191036 }
10201037
10211038 /* Start Ampli */
1022- popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1039+ fp = popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1040+ if (fp != NULL ) {
1041+ pclose (fp);
1042+ }
10231043}
10241044
10251045
@@ -1042,9 +1062,13 @@ int launch_resume_menu_loop()
10421062 uint8_t screen_refresh = 1 ;
10431063 uint8_t menu_confirmation = 0 ;
10441064 int option_idx=RESUME_YES;
1065+ FILE *fp;
10451066
10461067 /* Stop Ampli */
1047- popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
1068+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
1069+ if (fp != NULL ) {
1070+ pclose (fp);
1071+ }
10481072
10491073 /* Save prev key repeat params and set new Key repeat */
10501074 SDL_GetKeyRepeat (&backup_key_repeat_delay, &backup_key_repeat_interval);
@@ -1209,7 +1233,10 @@ int launch_resume_menu_loop()
12091233 }
12101234
12111235 /* Start Ampli */
1212- popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1236+ fp = popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1237+ if (fp != NULL ) {
1238+ pclose (fp);
1239+ }
12131240
12141241 return option_idx;
12151242}
0 commit comments