@@ -431,6 +431,7 @@ void init_menu_system_values(){
431431 }
432432 else {
433433 fgets (res , sizeof (res )- 1 , fp );
434+ pclose (fp );
434435
435436 /// Check if Volume is a number (at least the first char)
436437 if (res [0 ] < '0' || res [0 ] > '9' ){
@@ -451,6 +452,7 @@ void init_menu_system_values(){
451452 }
452453 else {
453454 fgets (res , sizeof (res )- 1 , fp );
455+ pclose (fp );
454456
455457 /// Check if brightness is a number (at least the first char)
456458 if (res [0 ] < '0' || res [0 ] > '9' ){
@@ -694,7 +696,10 @@ void run_menu_loop()
694696 RES_HW_SCREEN_HORIZONTAL * RES_HW_SCREEN_VERTICAL * sizeof (uint16_t ));
695697
696698 /* Stop Ampli */
697- popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
699+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
700+ if (fp != NULL ) {
701+ pclose (fp );
702+ }
698703
699704 /// ------ Wait for menu UP key event ------
700705 int actions [IN_BINDTYPE_COUNT ] = { 0 , };
@@ -787,6 +792,8 @@ void run_menu_loop()
787792 fp = popen (shell_cmd , "r" );
788793 if (fp == NULL ) {
789794 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
795+ } else {
796+ pclose (fp );
790797 }
791798
792799 /// ------ Refresh screen ------
@@ -803,6 +810,8 @@ void run_menu_loop()
803810 fp = popen (shell_cmd , "r" );
804811 if (fp == NULL ) {
805812 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
813+ } else {
814+ pclose (fp );
806815 }
807816 /// ------ Refresh screen ------
808817 screen_refresh = 1 ;
@@ -859,6 +868,8 @@ void run_menu_loop()
859868 fp = popen (shell_cmd , "r" );
860869 if (fp == NULL ) {
861870 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
871+ } else {
872+ pclose (fp );
862873 }
863874 /// ------ Refresh screen ------
864875 screen_refresh = 1 ;
@@ -874,6 +885,8 @@ void run_menu_loop()
874885 fp = popen (shell_cmd , "r" );
875886 if (fp == NULL ) {
876887 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
888+ } else {
889+ pclose (fp );
877890 }
878891 /// ------ Refresh screen ------
879892 screen_refresh = 1 ;
@@ -940,6 +953,8 @@ void run_menu_loop()
940953 fp = popen (shell_cmd , "r" );
941954 if (fp == NULL ) {
942955 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
956+ } else {
957+ pclose (fp );
943958 }
944959
945960 stop_menu_loop = 1 ;
@@ -985,6 +1000,8 @@ void run_menu_loop()
9851000 fp = popen (shell_cmd , "r" );
9861001 if (fp == NULL ) {
9871002 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
1003+ } else {
1004+ pclose (fp );
9881005 }
9891006
9901007 /*snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "LOADED" : "FAIL!");
@@ -1082,7 +1099,10 @@ void run_menu_loop()
10821099 }
10831100
10841101 /* Start Ampli */
1085- popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1102+ fp = popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1103+ if (fp != NULL ) {
1104+ pclose (fp );
1105+ }
10861106
10871107 /// ------ Reset last screen ------
10881108 SDL_BlitSurface (backup_hw_screen , NULL , hw_screen , NULL );
@@ -1109,12 +1129,16 @@ int launch_resume_menu_loop()
11091129 uint32_t prev_ms = SDL_GetTicks ();
11101130 uint32_t cur_ms = SDL_GetTicks ();
11111131 stop_menu_loop = 0 ;
1132+ FILE * fp ;
11121133 uint8_t screen_refresh = 1 ;
11131134 uint8_t menu_confirmation = 0 ;
11141135 int option_idx = RESUME_YES ;
11151136
11161137 /* Stop Ampli */
1117- popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
1138+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
1139+ if (fp != NULL ) {
1140+ pclose (fp );
1141+ }
11181142
11191143 /* Save prev key repeat params and set new Key repeat */
11201144 SDL_GetKeyRepeat (& backup_key_repeat_delay , & backup_key_repeat_interval );
@@ -1283,7 +1307,10 @@ int launch_resume_menu_loop()
12831307 }
12841308
12851309 /* Start Ampli */
1286- popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1310+ fp = popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1311+ if (fp != NULL ) {
1312+ pclose (fp );
1313+ }
12871314
12881315 return option_idx ;
12891316}
0 commit comments