@@ -380,6 +380,7 @@ void init_menu_system_values(){
380380 volume_percentage = 50 ; ///wrong value: setting default to 50
381381 }
382382 else {
383+ pclose (fp );
383384 fgets (res , sizeof (res )- 1 , fp );
384385
385386 /// Check if Volume is a number (at least the first char)
@@ -400,6 +401,7 @@ void init_menu_system_values(){
400401 brightness_percentage = 50 ; ///wrong value: setting default to 50
401402 }
402403 else {
404+ pclose (fp );
403405 fgets (res , sizeof (res )- 1 , fp );
404406
405407 /// Check if brightness is a number (at least the first char)
@@ -638,7 +640,10 @@ void run_menu_loop()
638640 }
639641
640642 /* Stop Ampli */
641- popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
643+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
644+ if (fp != NULL ) {
645+ pclose (fp );
646+ }
642647
643648 /// -------- Main loop ---------
644649 while (!stop_menu_loop )
@@ -718,7 +723,9 @@ void run_menu_loop()
718723 fp = popen (shell_cmd , "r" );
719724 if (fp == NULL ) {
720725 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
721- }
726+ } else {
727+ pclose (fp );
728+ }
722729
723730 /// ------ Refresh screen ------
724731 screen_refresh = 1 ;
@@ -734,6 +741,8 @@ void run_menu_loop()
734741 fp = popen (shell_cmd , "r" );
735742 if (fp == NULL ) {
736743 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
744+ } else {
745+ pclose (fp );
737746 }
738747 /// ------ Refresh screen ------
739748 screen_refresh = 1 ;
@@ -790,7 +799,10 @@ void run_menu_loop()
790799 fp = popen (shell_cmd , "r" );
791800 if (fp == NULL ) {
792801 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
793- }
802+ } else {
803+ pclose (fp );
804+ }
805+
794806 /// ------ Refresh screen ------
795807 screen_refresh = 1 ;
796808 }
@@ -805,6 +817,8 @@ void run_menu_loop()
805817 fp = popen (shell_cmd , "r" );
806818 if (fp == NULL ) {
807819 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
820+ } else {
821+ pclose (fp );
808822 }
809823 /// ------ Refresh screen ------
810824 screen_refresh = 1 ;
@@ -863,6 +877,8 @@ void run_menu_loop()
863877 fp = popen (shell_cmd , "r" );
864878 if (fp == NULL ) {
865879 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
880+ } else {
881+ pclose (fp );
866882 }
867883
868884 stop_menu_loop = 1 ;
@@ -900,6 +916,8 @@ void run_menu_loop()
900916 fp = popen (shell_cmd , "r" );
901917 if (fp == NULL ) {
902918 MENU_ERROR_PRINTF ("Failed to run command %s\n" , shell_cmd );
919+ } else {
920+ pclose (fp );
903921 }
904922
905923 stop_menu_loop = 1 ;
@@ -995,7 +1013,10 @@ void run_menu_loop()
9951013 }
9961014
9971015 /* Start Ampli */
998- popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1016+ fp = popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1017+ if (fp != NULL ) {
1018+ pclose (fp );
1019+ }
9991020}
10001021
10011022
@@ -1018,9 +1039,13 @@ int launch_resume_menu_loop()
10181039 uint8_t screen_refresh = 1 ;
10191040 uint8_t menu_confirmation = 0 ;
10201041 int option_idx = RESUME_YES ;
1042+ FILE * fp ;
10211043
10221044 /* Stop Ampli */
1023- popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
1045+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF , "r" );
1046+ if (fp != NULL ) {
1047+ pclose (fp );
1048+ }
10241049
10251050 /* Save prev key repeat params and set new Key repeat */
10261051 SDL_GetKeyRepeat (& backup_key_repeat_delay , & backup_key_repeat_interval );
@@ -1193,7 +1218,10 @@ int launch_resume_menu_loop()
11931218 }
11941219
11951220 /* Start Ampli */
1196- popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1221+ fp = popen (SHELL_CMD_TURN_AMPLI_ON , "r" );
1222+ if (fp != NULL ) {
1223+ pclose (fp );
1224+ }
11971225
11981226 return option_idx ;
11991227}
0 commit comments